import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from cycler import cycler
+from collections import OrderedDict
def rename_cols(df):
- new_cols = {'baseline_1thr_pereventmean': 'basel_1thr',
- 'baseline_2thr_pereventmean': 'basel_2thr',
- 'baseline_4thr_pereventmean': 'basel_4thr',
- 'baseline_8thr_pereventmean': 'basel_8thr',
- 'baseline_16thr_pereventmean': 'basel_16thr',
- 'lttng_1thr_pereventmean': 'lttng_1thr',
- 'lttng_2thr_pereventmean': 'lttng_2thr',
- 'lttng_4thr_pereventmean': 'lttng_4thr',
- 'lttng_8thr_pereventmean': 'lttng_8thr',
- 'lttng_16thr_pereventmean': 'lttng_16thr'
+ new_cols = {'baseline_1thr_peritermean': 'basel_1thr',
+ 'baseline_2thr_peritermean': 'basel_2thr',
+ 'baseline_4thr_peritermean': 'basel_4thr',
+ 'baseline_8thr_peritermean': 'basel_8thr',
+ 'baseline_16thr_peritermean': 'basel_16thr',
+ 'lttng_1thr_peritermean': 'lttng_1thr',
+ 'lttng_2thr_peritermean': 'lttng_2thr',
+ 'lttng_4thr_peritermean': 'lttng_4thr',
+ 'lttng_8thr_peritermean': 'lttng_8thr',
+ 'lttng_16thr_peritermean': 'lttng_16thr',
+ 'baseline_1thr_periterstdev': 'basel_1thr_stdev',
+ 'baseline_2thr_periterstdev': 'basel_2thr_stdev',
+ 'baseline_4thr_periterstdev': 'basel_4thr_stdev',
+ 'baseline_8thr_periterstdev': 'basel_8thr_stdev',
+ 'baseline_16thr_periterstdev': 'basel_16thr_stdev',
+ 'lttng_1thr_periterstdev': 'lttng_1thr_stdev',
+ 'lttng_2thr_periterstdev': 'lttng_2thr_stdev',
+ 'lttng_4thr_periterstdev': 'lttng_4thr_stdev',
+ 'lttng_8thr_periterstdev': 'lttng_8thr_stdev',
+ 'lttng_16thr_periterstdev': 'lttng_16thr_stdev'
}
df.rename(columns=new_cols, inplace=True)
return df
-def create_plot(df, graph_type):
- # We split the data into two plots so it's easier to read
- lower = ['basel_1thr', 'basel_2thr', 'basel_4thr', 'lttng_1thr', 'lttng_2thr', 'lttng_4thr']
- lower_color = ['lightcoral', 'gray', 'chartreuse', 'red', 'black', 'forestgreen']
- upper = ['basel_8thr', 'basel_16thr', 'lttng_8thr', 'lttng_16thr']
- upper_color = ['deepskyblue', 'orange', 'mediumblue', 'saddlebrown']
-
-
- title='Meantime per syscalls for {} testcase'.format(graph_type)
+def convert_us_to_ns(df):
+ cols = [col for col in df.columns if 'periter' in col]
+ df[cols] = df[cols].apply(lambda x: x*1000)
+ return df
- # Create a plot with 2 sub-plots
- f, arrax = plt.subplots(2, sharex=True, figsize=(12, 14))
+def create_plot(df, graph_type):
+ # We map all test configurations and their
+ # respective color
+ conf_to_color = OrderedDict([
+ ('basel_1thr','lightcoral'),
+ ('lttng_1thr','red'),
+ ('basel_2thr','gray'),
+ ('lttng_2thr','black'),
+ ('basel_4thr','chartreuse'),
+ ('lttng_4thr','forestgreen'),
+ ('basel_8thr','deepskyblue'),
+ ('lttng_8thr','mediumblue'),
+ ('basel_16thr','orange'),
+ ('lttng_16thr','saddlebrown')])
+
+ # We create a list for each of the subplots
+ baseline = [x for x in conf_to_color.keys() if 'basel' in x]
+ lttng = [x for x in conf_to_color.keys() if 'lttng' in x]
+ one_thr = [x for x in conf_to_color.keys() if '_1thr' in x]
+ two_thr = [x for x in conf_to_color.keys() if '_2thr' in x]
+ four_thr = [x for x in conf_to_color.keys() if '_4thr' in x]
+ eight_thr = [x for x in conf_to_color.keys() if '_8thr' in x]
+ sixteen_thr = [x for x in conf_to_color.keys() if '_16thr' in x]
+
+ plots = [baseline, lttng, one_thr, two_thr, four_thr, eight_thr, sixteen_thr]
+
+ title='Meantime per event for {} testcase'.format(graph_type)
+
+ # Create a axe object for each sub-plots
+ f, arrax = plt.subplots(len(plots), sharex=True, figsize=(16, 25))
+ f.suptitle(title, fontsize=20)
+
+ for (ax, data_cols) in zip(arrax, plots):
+ curr_df = df[data_cols]
+
+ stdev_cols = ['{}_stdev'.format(x) for x in data_cols]
+ # Extract the color for each configuration
+ colors = [conf_to_color[x] for x in data_cols]
+
+ # set the color cycler for this plot
+ ax.set_prop_cycle(cycler('color', colors))
- f.suptitle(title, fontsize=18)
+ # Plot each line and its errorbars
+ for (data, stdev) in zip(data_cols, stdev_cols):
+ ax.errorbar(x=df.index.values, y=df[data].values, yerr=df[stdev].values, marker='o')
- for (ax, sub, colors) in zip(arrax, [lower, upper], [lower_color,upper_color]):
- curr_df = df[sub]
- ax.set_prop_cycle(cycler('color', colors))
- ax.plot(curr_df, marker='o')
ax.set_ylim(0)
ax.grid()
ax.set_xlabel('Jenkins Build ID')
- ax.set_ylabel('Meantime per syscall [ns]')
- ax.legend(labels=curr_df.columns.values, bbox_to_anchor=(1.2,1))
- ax.xaxis.set_major_locator(MaxNLocator(integer=True))
+ ax.set_ylabel('Meantime per event [us]')
+
+ ax.xaxis.set_major_locator(MaxNLocator(integer=True, nbins=30))
+
+ ax.legend(prop={'family': 'monospace'},
+ labels=curr_df.columns.values, bbox_to_anchor=(1.2,1))
+ plt.subplots_adjust(top=0.95)
plt.savefig('{}.png'.format(graph_type), bbox_inches='tight')
# Writes a file that contains commit id of all configurations shown in the
for dirname, dirnames, res_files in os.walk('./'+res_dir):
if len(dirnames) > 0:
continue
- metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
+ try:
+ metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
+ except Exception:
+ print('Omitting run {} because metadata.csv is missing'.format(dirname))
+ continue
list_.append(metadata)
df = pd.concat(list_)
for dirname, dirnames, res_files in os.walk('./'+res_dir):
if len(dirnames) > 0:
continue
- metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
+ try:
+ metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
+ except Exception:
+ print('Omitting run {} because metadata.csv is missing'.format(dirname))
+ continue
for res in res_files:
if res in 'metadata.csv':
list_.append(tmp)
df = pd.concat(list_)
+ df = convert_us_to_ns(df)
df = rename_cols(df)
df.sort_index(inplace=True)