@@ -87,6 +87,25 @@ def graph_results(benchmark_results, out_dir):
87
87
:type benchmark_results: BenchmarkResults
88
88
:type out_dir str
89
89
"""
90
+ def name_file (benchmark_function_name , data_size , max_container_size ):
91
+ type = None
92
+ for potential_type in ['vector' , 'set' , 'map' ]:
93
+ if ("_%s_" % potential_type ) in benchmark_function_name :
94
+ type = potential_type
95
+ break
96
+
97
+ op_decoder = {
98
+ 'rand_read' : 'Random reads' ,
99
+ 'sequential_read' : 'Sequential reads' ,
100
+ 'insert' : 'Insertion' ,
101
+ 'lookup' : 'Random lookup' ,
102
+ 'set_read' : 'Random lookup' ,
103
+ }
104
+ for function_partial_name , decoded in op_decoder .items ():
105
+ if function_partial_name in benchmark_function_name :
106
+ return "%s in %ss up to %d elements (%d byte data).png" % (decoded , type , max_container_size , data_size )
107
+ return "%s_data_size_%d.png" % (benchmark_fn , data_size )
108
+
90
109
try :
91
110
os .makedirs (out_dir )
92
111
except os .error :
@@ -95,11 +114,13 @@ def graph_results(benchmark_results, out_dir):
95
114
for benchmark_fn , data_sizes_for_fn in benchmark_results .data .items ():
96
115
for data_size , container_types_at_size in data_sizes_for_fn .items ():
97
116
# Make a graph of the time required of each container type with this data size and any number of elements
117
+ max_cardinality = 0
98
118
traces = []
99
119
for container_type , num_elements_for_container in container_types_at_size .items ():
100
120
times = [] # CPU time in nanoseconds
101
121
for cardinality in benchmark_results .cardinalities :
102
122
times .append (num_elements_for_container [cardinality ])
123
+ max_cardinality = max (max_cardinality , cardinality )
103
124
traces .append (plotly .graph_objs .Scatter (
104
125
x = benchmark_results .cardinalities ,
105
126
y = times ,
@@ -115,7 +136,8 @@ def graph_results(benchmark_results, out_dir):
115
136
# plotly.offline.plot(figure,
116
137
# filename="%s_data_size_%d.html" % (benchmark_fn, data_size),
117
138
# auto_open=False)
118
- plotly .io .write_image (figure , os .path .join (out_dir , "%s_data_size_%d.png" % (benchmark_fn , data_size )))
139
+ plotly .io .write_image (figure , os .path .join (out_dir ,
140
+ name_file (benchmark_fn , data_size , max_cardinality )))
119
141
120
142
# We need separate graphs by container size.
121
143
# E.g., if you know your container will have 8 elements, here's the fastest container for iteration.
0 commit comments