jjb: lttng-tools: Add debug-rcu conf for 2.7, 2.8, 2.9
[lttng-ci.git] / scripts / lttng-baremetal-tests / generate-plots.py
index 1db638a9216fc6d00b88269d3926b535fdf0ea68..03a4e18df7eaad1eb2539b423ee3b5ef1b0a0efd 100644 (file)
@@ -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,37 +37,83 @@ 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
 
-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']
+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
 
+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 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], yerr=df[stdev], 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.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
@@ -76,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_)
@@ -93,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':
@@ -106,6 +161,7 @@ def create_plots(res_dir):
             list_.append(tmp)
 
         df = pd.concat(list_)
+        df = convert_us_to_ns(df)
         df = rename_cols(df)
         df.sort_index(inplace=True)
 
This page took 0.023567 seconds and 4 git commands to generate.