@@ -17,31 +17,37 @@ def __init__(self, benchmarks: pd.DataFrame, dir: str):
17
17
"zod" : "#e377c2" ,
18
18
}
19
19
self .metrics = [
20
- "Memory used" ,
21
- "Program time" ,
22
- "Check time" ,
23
- "Total time" ,
20
+ {"name" : "Memory used" , "unit" : "Megabytes" },
21
+ {"name" : "Program time" , "unit" : "Seconds" },
22
+ {"name" : "Check time" , "unit" : "Seconds" },
23
+ {"name" : "Total time" , "unit" : "Seconds" },
24
+ {"name" : "Identifiers" , "unit" : "Count" },
25
+ {"name" : "Types" , "unit" : "Count" },
26
+ {"name" : "Symbols" , "unit" : "Count" },
27
+ {"name" : "I/O Read time" , "unit" : "Seconds" },
24
28
]
25
29
26
30
def plot (self ):
27
31
for metric in self .metrics :
28
- self ._plotMetric (metric )
32
+ self ._plotMetric (metricName = metric [ "name" ], unit = metric [ "unit" ] )
29
33
30
- def _plotMetric (self , metric : str ):
34
+ def _plotMetric (self , metricName : str , unit : str ):
31
35
df = self .benchmarks .reset_index ()
32
- df = df [["Name" , "Library" , metric ]]
33
- df = df .sort_values (by = [metric ], ascending = False )
36
+ df = df [["Name" , "Library" , metricName ]]
37
+ df = df .sort_values (by = [metricName ], ascending = False )
34
38
grouped = df .groupby (by = ["Name" ])
35
39
36
40
fig = plt .figure (figsize = (8 , 12 ))
37
- fig .suptitle (f'{ metric } comparison' , fontsize = 24 )
41
+ fig .suptitle (f'{ metricName } comparison' , fontsize = 24 )
38
42
39
43
for i , (names , group ) in enumerate (grouped ):
40
44
ax = plt .subplot (len (grouped ), 1 , i + 1 )
41
45
colors = [self .colorMap [lib ] for lib in group ["Library" ]]
42
- ax .barh (y = group ["Library" ], width = group [metric ], color = colors )
46
+ ax .barh (y = group ["Library" ], width = group [metricName ], color = colors )
43
47
ax .set_title (names [0 ])
48
+ ax .set_xlabel (unit )
44
49
ax .plot ()
45
50
46
- plt .subplots_adjust (wspace = 0 , hspace = 0.5 )
47
- plt .savefig (os .path .join (self .dir , f"{ metric } .png" ))
51
+ fileName = metricName .replace (" " , "_" ).replace ("/" , "_" ).lower ()
52
+ plt .subplots_adjust (wspace = 0 , hspace = 0.8 )
53
+ plt .savefig (os .path .join (self .dir , f"{ fileName } .png" ))
0 commit comments