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 convert_us_to_ns(df
):
45 cols
= [col
for col
in df
.columns
if 'periter' in col
]
46 df
[cols
] = df
[cols
].apply(lambda x
: x
*1000)
49 def create_plot(df
, graph_type
):
50 # We split the data into two plots so it's easier to read
51 lower
= ['basel_1thr', 'basel_2thr', 'basel_4thr', 'lttng_1thr', 'lttng_2thr', 'lttng_4thr']
52 lower_color
= ['lightcoral', 'gray', 'chartreuse', 'red', 'black', 'forestgreen']
53 upper
= ['basel_8thr', 'basel_16thr', 'lttng_8thr', 'lttng_16thr']
54 upper_color
= ['deepskyblue', 'orange', 'mediumblue', 'saddlebrown']
56 title
='Meantime per syscalls for {} testcase'.format(graph_type
)
58 # Create a plot with 2 sub-plots
59 f
, arrax
= plt
.subplots(2, sharex
=True, figsize
=(12, 14))
61 f
.suptitle(title
, fontsize
=18)
63 for (ax
, sub
, colors
) in zip(arrax
, [lower
, upper
], [lower_color
,upper_color
]):
65 ax
.set_prop_cycle(cycler('color', colors
))
66 ax
.plot(curr_df
, marker
='o')
69 ax
.set_xlabel('Jenkins Build ID')
70 ax
.set_ylabel('Meantime per syscall [us]')
71 ax
.legend(labels
=curr_df
.columns
.values
, bbox_to_anchor
=(1.2,1))
72 ax
.xaxis
.set_major_locator(MaxNLocator(integer
=True))
74 plt
.savefig('{}.png'.format(graph_type
), bbox_inches
='tight')
76 # Writes a file that contains commit id of all configurations shown in the
78 def create_metadata_file(res_dir
):
80 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
83 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
84 list_
.append(metadata
)
88 df
.sort_index(inplace
=True)
89 df
.to_csv('metadata.csv', index
=False)
91 #Iterates over a result directory and creates the plots for the different
93 def create_plots(res_dir
):
95 metadata_df
= pd
.DataFrame()
97 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
100 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
102 for res
in res_files
:
103 if res
in 'metadata.csv':
105 tmp
= pd
.read_csv(os
.path
.join(dirname
, res
))
106 #Use the build id as the index for the dataframe for filtering
107 tmp
.index
= metadata
.build_id
108 #Add the testcase name to the row for later filtering
109 tmp
['testcase'] = res
.split('.')[0]
112 df
= pd
.concat(list_
)
113 df
= convert_us_to_ns(df
)
115 df
.sort_index(inplace
=True)
117 #Go over the entire dataframe by testcase and create a plot for each type
118 for testcase
in df
.testcase
.unique():
119 df_testcase
= df
.loc
[df
['testcase'] == testcase
]
120 create_plot(df
=df_testcase
, graph_type
=testcase
)
123 res_path
= sys
.argv
[1]
124 create_plots(os
.path
.join(res_path
))
125 create_metadata_file(os
.path
.join(res_path
))
127 if __name__
== '__main__':
This page took 0.033001 seconds and 5 git commands to generate.