@@ -87,6 +87,25 @@ def graph_results(benchmark_results, out_dir):
8787 :type benchmark_results: BenchmarkResults
8888 :type out_dir str
8989 """
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+
90109 try :
91110 os .makedirs (out_dir )
92111 except os .error :
@@ -95,11 +114,13 @@ def graph_results(benchmark_results, out_dir):
95114 for benchmark_fn , data_sizes_for_fn in benchmark_results .data .items ():
96115 for data_size , container_types_at_size in data_sizes_for_fn .items ():
97116 # Make a graph of the time required of each container type with this data size and any number of elements
117+ max_cardinality = 0
98118 traces = []
99119 for container_type , num_elements_for_container in container_types_at_size .items ():
100120 times = [] # CPU time in nanoseconds
101121 for cardinality in benchmark_results .cardinalities :
102122 times .append (num_elements_for_container [cardinality ])
123+ max_cardinality = max (max_cardinality , cardinality )
103124 traces .append (plotly .graph_objs .Scatter (
104125 x = benchmark_results .cardinalities ,
105126 y = times ,
@@ -115,7 +136,8 @@ def graph_results(benchmark_results, out_dir):
115136 # plotly.offline.plot(figure,
116137 # filename="%s_data_size_%d.html" % (benchmark_fn, data_size),
117138 # 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 )))
119141
120142 # We need separate graphs by container size.
121143 # E.g., if you know your container will have 8 elements, here's the fastest container for iteration.
0 commit comments