X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Flttng-baremetal-tests%2Fgenerate-plots.py;h=89f6084ec072889e15cc70fb4e13d036680f1565;hb=bb43133fa152270933f7d92a68a1dedf9db6e58b;hp=87ce64cb03cbdad7ca9160bdaf90feb18276444b;hpb=c5545ca02fb63a21156a4a0ac22f58c067a43f12;p=lttng-ci.git diff --git a/scripts/lttng-baremetal-tests/generate-plots.py b/scripts/lttng-baremetal-tests/generate-plots.py index 87ce64c..89f6084 100644 --- a/scripts/lttng-baremetal-tests/generate-plots.py +++ b/scripts/lttng-baremetal-tests/generate-plots.py @@ -25,6 +25,7 @@ mpl.use('Agg') 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_peritermean': 'basel_1thr', @@ -36,7 +37,17 @@ def rename_cols(df): 'lttng_2thr_peritermean': 'lttng_2thr', 'lttng_4thr_peritermean': 'lttng_4thr', 'lttng_8thr_peritermean': 'lttng_8thr', - 'lttng_16thr_peritermean': 'lttng_16thr' + '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 @@ -47,30 +58,62 @@ def convert_us_to_ns(df): 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'] + # 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 syscalls for {} testcase'.format(graph_type) - # Create a plot with 2 sub-plots - f, arrax = plt.subplots(2, sharex=True, figsize=(12, 14)) + # Create a axe object for each sub-plots + f, arrax = plt.subplots(len(plots), sharex=True, figsize=(16, 25)) + f.suptitle(title, fontsize=20) - f.suptitle(title, fontsize=18) + for (ax, data_cols) in zip(arrax, plots): + curr_df = df[data_cols] - for (ax, sub, colors) in zip(arrax, [lower, upper], [lower_color,upper_color]): - curr_df = df[sub] + 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)) - ax.plot(curr_df, marker='o') + + # 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') + ax.set_ylim(0) ax.grid() ax.set_xlabel('Jenkins Build ID') ax.set_ylabel('Meantime per syscall [us]') - ax.legend(labels=curr_df.columns.values, bbox_to_anchor=(1.2,1)) - ax.xaxis.set_major_locator(MaxNLocator(integer=True)) + 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 @@ -80,7 +123,11 @@ def create_metadata_file(res_dir): 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_) @@ -97,7 +144,11 @@ def create_plots(res_dir): 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':