1 # Copyright (C) 2017 - Francis Deslauriers <francis.deslauriers@efficios.com>
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.
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.
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/>.
21 #Set Matplotlib to use the PNG non interactive backend
22 import matplotlib
as mpl
25 import matplotlib
.pyplot
as plt
26 from matplotlib
.ticker
import MaxNLocator
27 from cycler
import cycler
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'
41 df
.rename(columns
=new_cols
, inplace
=True)
44 def 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']
52 title
='Meantime per syscalls for {} testcase'.format(graph_type
)
54 # Create a plot with 2 sub-plots
55 f
, arrax
= plt
.subplots(2, sharex
=True, figsize
=(12, 14))
57 f
.suptitle(title
, fontsize
=18)
59 for (ax
, sub
, colors
) in zip(arrax
, [lower
, upper
], [lower_color
,upper_color
]):
61 ax
.set_prop_cycle(cycler('color', colors
))
62 ax
.plot(curr_df
, marker
='o')
65 ax
.set_xlabel('Jenkins Build ID')
66 ax
.set_ylabel('Meantime per syscall [us]')
67 ax
.legend(labels
=curr_df
.columns
.values
, bbox_to_anchor
=(1.2,1))
68 ax
.xaxis
.set_major_locator(MaxNLocator(integer
=True))
70 plt
.savefig('{}.png'.format(graph_type
), bbox_inches
='tight')
72 # Writes a file that contains commit id of all configurations shown in the
74 def create_metadata_file(res_dir
):
76 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
79 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
80 list_
.append(metadata
)
84 df
.sort_index(inplace
=True)
85 df
.to_csv('metadata.csv', index
=False)
87 #Iterates over a result directory and creates the plots for the different
89 def create_plots(res_dir
):
91 metadata_df
= pd
.DataFrame()
93 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
96 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
99 if res
in 'metadata.csv':
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]
108 df
= pd
.concat(list_
)
110 df
.sort_index(inplace
=True)
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
)
118 res_path
= sys
.argv
[1]
119 create_plots(os
.path
.join(res_path
))
120 create_metadata_file(os
.path
.join(res_path
))
122 if __name__
== '__main__':
This page took 0.036384 seconds and 5 git commands to generate.