Lava: Consider threads when computing time per event
[lttng-ci.git] / scripts / lttng-baremetal-tests / generate-plots.py
CommitLineData
b87dc589
FD
1# Copyright (C) 2017 - Francis Deslauriers <francis.deslauriers@efficios.com>
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17import os, sys
18import numpy as np
19import pandas as pd
20
21#Set Matplotlib to use the PNG non interactive backend
22import matplotlib as mpl
23mpl.use('Agg')
24
25import matplotlib.pyplot as plt
26from matplotlib.ticker import MaxNLocator
27from cycler import cycler
28
29def rename_cols(df):
f758d98b
FD
30 new_cols = {'baseline_1thr_peritermean': 'basel_1thr',
31 'baseline_2thr_peritermean': 'basel_2thr',
32 'baseline_4thr_peritermean': 'basel_4thr',
33 'baseline_8thr_peritermean': 'basel_8thr',
34 'baseline_16thr_peritermean': 'basel_16thr',
35 'lttng_1thr_peritermean': 'lttng_1thr',
36 'lttng_2thr_peritermean': 'lttng_2thr',
37 'lttng_4thr_peritermean': 'lttng_4thr',
38 'lttng_8thr_peritermean': 'lttng_8thr',
39 'lttng_16thr_peritermean': 'lttng_16thr'
b87dc589
FD
40 }
41 df.rename(columns=new_cols, inplace=True)
42 return df
43
44def create_plot(df, graph_type):
45 # We split the data into two plots so it's easier to read
46 lower = ['basel_1thr', 'basel_2thr', 'basel_4thr', 'lttng_1thr', 'lttng_2thr', 'lttng_4thr']
47 lower_color = ['lightcoral', 'gray', 'chartreuse', 'red', 'black', 'forestgreen']
48 upper = ['basel_8thr', 'basel_16thr', 'lttng_8thr', 'lttng_16thr']
49 upper_color = ['deepskyblue', 'orange', 'mediumblue', 'saddlebrown']
50
51
52 title='Meantime per syscalls for {} testcase'.format(graph_type)
53
54 # Create a plot with 2 sub-plots
55 f, arrax = plt.subplots(2, sharex=True, figsize=(12, 14))
56
57 f.suptitle(title, fontsize=18)
58
59 for (ax, sub, colors) in zip(arrax, [lower, upper], [lower_color,upper_color]):
60 curr_df = df[sub]
61 ax.set_prop_cycle(cycler('color', colors))
62 ax.plot(curr_df, marker='o')
63 ax.set_ylim(0)
64 ax.grid()
65 ax.set_xlabel('Jenkins Build ID')
f758d98b 66 ax.set_ylabel('Meantime per syscall [us]')
b87dc589
FD
67 ax.legend(labels=curr_df.columns.values, bbox_to_anchor=(1.2,1))
68 ax.xaxis.set_major_locator(MaxNLocator(integer=True))
69
70 plt.savefig('{}.png'.format(graph_type), bbox_inches='tight')
71
72# Writes a file that contains commit id of all configurations shown in the
73# plots
74def create_metadata_file(res_dir):
75 list_ = []
76 for dirname, dirnames, res_files in os.walk('./'+res_dir):
77 if len(dirnames) > 0:
78 continue
79 metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
80 list_.append(metadata)
81
82 df = pd.concat(list_)
83 df.index=df.build_id
84 df.sort_index(inplace=True)
85 df.to_csv('metadata.csv', index=False)
86
87#Iterates over a result directory and creates the plots for the different
88#testcases
89def create_plots(res_dir):
90 df = pd.DataFrame()
91 metadata_df = pd.DataFrame()
92 list_ = []
93 for dirname, dirnames, res_files in os.walk('./'+res_dir):
94 if len(dirnames) > 0:
95 continue
96 metadata = pd.read_csv(os.path.join(dirname, 'metadata.csv'))
97
98 for res in res_files:
99 if res in 'metadata.csv':
100 continue
101 tmp = pd.read_csv(os.path.join(dirname, res))
102 #Use the build id as the index for the dataframe for filtering
103 tmp.index = metadata.build_id
104 #Add the testcase name to the row for later filtering
105 tmp['testcase'] = res.split('.')[0]
106 list_.append(tmp)
107
108 df = pd.concat(list_)
109 df = rename_cols(df)
110 df.sort_index(inplace=True)
111
112 #Go over the entire dataframe by testcase and create a plot for each type
113 for testcase in df.testcase.unique():
114 df_testcase = df.loc[df['testcase'] == testcase]
115 create_plot(df=df_testcase, graph_type=testcase)
116
117def main():
118 res_path = sys.argv[1]
119 create_plots(os.path.join(res_path))
120 create_metadata_file(os.path.join(res_path))
121
122if __name__ == '__main__':
123 main()
This page took 0.026307 seconds and 4 git commands to generate.