14
14
import itertools
15
15
import seaborn as sns
16
16
import pandas as pd
17
+ from numpy import median
17
18
18
19
#%%
19
20
@@ -59,37 +60,41 @@ def load_processed(filepath):
59
60
processed = load_data (filepath )
60
61
61
62
62
- labels = []
63
- values = []
63
+ times = []
64
+ sizes = []
65
+ time_per_element = []
66
+ functions = []
64
67
for k , g in itertools .groupby (processed , lambda el : (el [0 ],el [1 ])):
65
- if k [0 ] == 'stratified' :
66
- for el in g :
67
- values .append (float (el [2 ]))
68
- labels .append (k [1 ])
68
+ for el in g :
69
+ times .append (float (el [2 ]))
70
+ sizes .append (k [1 ])
71
+ time_per_element .append (float (el [2 ]) / float (k [1 ][:- 1 ]) ** 2 )
72
+ functions .append (k [0 ])
69
73
70
- return values , labels
74
+ return times , sizes , functions , time_per_element
71
75
72
76
#%%
73
77
74
78
def draw_boxplots (fig , df ):
75
79
76
80
ax = fig .axes [0 ]
77
81
78
- ax = sns .boxplot (x = "size" , y = "values " , hue = "omp" , data = df , ax = ax , linewidth = 1.0 , fliersize = 2.0 )
82
+ ax = sns .barplot (x = "kernel size" , y = "time_per_element " , hue = "omp" , data = df , ax = ax )
79
83
80
84
ax .get_yaxis ().set_label_text ("Time (ns)" )
81
85
82
86
# ax.set_ylim(0, 3000000)
83
- ax .set_yscale ('log' )
84
87
88
+ # ax.set_yscale('log')
85
89
86
- def create_fig ():
90
+
91
+ def create_fig (function ):
87
92
fig = matplotlib .figure .Figure ()
88
93
FigureCanvas (fig )
89
94
90
95
ax = fig .add_subplot (111 )
91
- # ax.set_yscale('log')
92
- ax .set_title ('Benchmarking times (stratified sampling)' )
96
+ # ax.set_yscale('log')
97
+ ax .set_title ('Time per element ({})' . format ( function ) )
93
98
sns .despine (ax = ax )
94
99
95
100
@@ -113,26 +118,20 @@ def flatten(list_of_lists):
113
118
114
119
sns .set (context = "talk" , style = "white" )
115
120
116
- fig = create_fig ()
117
-
118
- data = { "size " : no_omp_proc [1 ] + omp_proc [1 ],
119
- "values " : no_omp_proc [0 ] + omp_proc [0 ],
121
+ data = { "kernel size" : no_omp_proc [ 1 ] + omp_proc [ 1 ],
122
+ "times" : no_omp_proc [ 0 ] + omp_proc [ 0 ],
123
+ "functions " : no_omp_proc [2 ] + omp_proc [2 ],
124
+ "time_per_element " : no_omp_proc [3 ] + omp_proc [3 ],
120
125
"omp" : ["No" ]* len (no_omp_proc [0 ]) + ["Yes" ] * len (omp_proc [0 ])}
121
126
122
- data2 = {"size" : flatten (zip (no_omp_proc [1 ], omp_proc [1 ])),
123
- "values" : flatten (zip (no_omp_proc [0 ], omp_proc [0 ])),
124
- "omp" : ["No" ]* len (no_omp_proc [0 ])* 2 }
125
-
126
127
df = pd .DataFrame (data = data )
127
128
128
129
#%%
129
130
130
- values = flatten (zip (no_omp_proc [0 ], omp_proc [0 ]))
131
- labels = flatten (zip (no_omp_proc [1 ], omp_proc [1 ]))
132
-
133
-
134
- draw_boxplots (fig , df )
131
+ for function , group in df .groupby (['functions' ]):
132
+ fig = create_fig (function )
133
+ draw_boxplots (fig , group )
134
+ save_fig (fig , "bench_{}.png" .format (function ))
135
135
136
- save_fig (fig , "bench.png" )
137
136
138
137
0 commit comments