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
28 from collections
import OrderedDict
31 new_cols
= {'baseline_1thr_peritermean': 'basel_1thr',
32 'baseline_2thr_peritermean': 'basel_2thr',
33 'baseline_4thr_peritermean': 'basel_4thr',
34 'baseline_8thr_peritermean': 'basel_8thr',
35 'baseline_16thr_peritermean': 'basel_16thr',
36 'lttng_1thr_peritermean': 'lttng_1thr',
37 'lttng_2thr_peritermean': 'lttng_2thr',
38 'lttng_4thr_peritermean': 'lttng_4thr',
39 'lttng_8thr_peritermean': 'lttng_8thr',
40 'lttng_16thr_peritermean': 'lttng_16thr',
41 'baseline_1thr_periterstdev': 'basel_1thr_stdev',
42 'baseline_2thr_periterstdev': 'basel_2thr_stdev',
43 'baseline_4thr_periterstdev': 'basel_4thr_stdev',
44 'baseline_8thr_periterstdev': 'basel_8thr_stdev',
45 'baseline_16thr_periterstdev': 'basel_16thr_stdev',
46 'lttng_1thr_periterstdev': 'lttng_1thr_stdev',
47 'lttng_2thr_periterstdev': 'lttng_2thr_stdev',
48 'lttng_4thr_periterstdev': 'lttng_4thr_stdev',
49 'lttng_8thr_periterstdev': 'lttng_8thr_stdev',
50 'lttng_16thr_periterstdev': 'lttng_16thr_stdev'
52 df
.rename(columns
=new_cols
, inplace
=True)
55 def convert_us_to_ns(df
):
56 cols
= [col
for col
in df
.columns
if 'periter' in col
]
57 df
[cols
] = df
[cols
].apply(lambda x
: x
*1000)
60 def create_plot(df
, graph_type
):
61 # We map all test configurations and their
63 conf_to_color
= OrderedDict([
64 ('basel_1thr','lightcoral'),
66 ('basel_2thr','gray'),
67 ('lttng_2thr','black'),
68 ('basel_4thr','chartreuse'),
69 ('lttng_4thr','forestgreen'),
70 ('basel_8thr','deepskyblue'),
71 ('lttng_8thr','mediumblue'),
72 ('basel_16thr','orange'),
73 ('lttng_16thr','saddlebrown')])
75 # We create a list for each of the subplots
76 baseline
= [x
for x
in conf_to_color
.keys() if 'basel' in x
]
77 lttng
= [x
for x
in conf_to_color
.keys() if 'lttng' in x
]
78 one_thr
= [x
for x
in conf_to_color
.keys() if '_1thr' in x
]
79 two_thr
= [x
for x
in conf_to_color
.keys() if '_2thr' in x
]
80 four_thr
= [x
for x
in conf_to_color
.keys() if '_4thr' in x
]
81 eight_thr
= [x
for x
in conf_to_color
.keys() if '_8thr' in x
]
82 sixteen_thr
= [x
for x
in conf_to_color
.keys() if '_16thr' in x
]
84 plots
= [baseline
, lttng
, one_thr
, two_thr
, four_thr
, eight_thr
, sixteen_thr
]
86 title
='Meantime per event for {} testcase'.format(graph_type
)
88 # Create a axe object for each sub-plots
89 f
, arrax
= plt
.subplots(len(plots
), sharex
=True, figsize
=(16, 25))
90 f
.suptitle(title
, fontsize
=20)
92 for (ax
, data_cols
) in zip(arrax
, plots
):
93 curr_df
= df
[data_cols
]
95 stdev_cols
= ['{}_stdev'.format(x
) for x
in data_cols
]
96 # Extract the color for each configuration
97 colors
= [conf_to_color
[x
] for x
in data_cols
]
99 # set the color cycler for this plot
100 ax
.set_prop_cycle(cycler('color', colors
))
102 # Plot each line and its errorbars
103 for (data
, stdev
) in zip(data_cols
, stdev_cols
):
104 ax
.errorbar(x
=df
.index
.values
, y
=df
[data
].values
, yerr
=df
[stdev
].values
, marker
='o')
108 ax
.set_xlabel('Jenkins Build ID')
109 ax
.set_ylabel('Meantime per event [us]')
111 ax
.xaxis
.set_major_locator(MaxNLocator(integer
=True, nbins
=30))
113 ax
.legend(prop
={'family': 'monospace'},
114 labels
=curr_df
.columns
.values
, bbox_to_anchor
=(1.2,1))
116 plt
.subplots_adjust(top
=0.95)
117 plt
.savefig('{}.png'.format(graph_type
), bbox_inches
='tight')
119 # Writes a file that contains commit id of all configurations shown in the
121 def create_metadata_file(res_dir
):
123 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
124 if len(dirnames
) > 0:
127 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
129 print('Omitting run {} because metadata.csv is missing'.format(dirname
))
131 list_
.append(metadata
)
133 df
= pd
.concat(list_
)
135 df
.sort_index(inplace
=True)
136 df
.to_csv('metadata.csv', index
=False)
138 #Iterates over a result directory and creates the plots for the different
140 def create_plots(res_dir
):
142 metadata_df
= pd
.DataFrame()
144 for dirname
, dirnames
, res_files
in os
.walk('./'+res_dir
):
145 if len(dirnames
) > 0:
148 metadata
= pd
.read_csv(os
.path
.join(dirname
, 'metadata.csv'))
150 print('Omitting run {} because metadata.csv is missing'.format(dirname
))
153 for res
in res_files
:
154 if res
in 'metadata.csv':
156 tmp
= pd
.read_csv(os
.path
.join(dirname
, res
))
157 #Use the build id as the index for the dataframe for filtering
158 tmp
.index
= metadata
.build_id
159 #Add the testcase name to the row for later filtering
160 tmp
['testcase'] = res
.split('.')[0]
163 df
= pd
.concat(list_
)
164 df
= convert_us_to_ns(df
)
166 df
.sort_index(inplace
=True)
168 #Go over the entire dataframe by testcase and create a plot for each type
169 for testcase
in df
.testcase
.unique():
170 df_testcase
= df
.loc
[df
['testcase'] == testcase
]
171 create_plot(df
=df_testcase
, graph_type
=testcase
)
174 res_path
= sys
.argv
[1]
175 create_plots(os
.path
.join(res_path
))
176 create_metadata_file(os
.path
.join(res_path
))
178 if __name__
== '__main__':
This page took 0.092173 seconds and 4 git commands to generate.