55csv_benchmark = sys .argv [1 ]
66csv_baseline = sys .argv [2 ]
77
8- def html_inline (x ):
9- if x == 0 :
10- color = "black"
11- x = "{:.1f}" .format (x )
12- elif x < 0 :
13- color = "green"
14- x = "{:.1f}" .format (x )
15- elif x > 0 :
16- color = "red"
17- x = "+{:.1f}" .format (x )
18- return f"<span style=\" color:{ color } \" >{ x } </span>"
8+ pretty = lambda x : "{:.1f}" .format (x ) if x <= 0 else "+{:.1f}" .format (x )
199
2010with open (csv_benchmark ) as csv_file :
2111 csv_reader = csv .reader (csv_file )
@@ -27,17 +17,17 @@ def html_inline(x):
2717 next (csv_reader )
2818 table_baseline = [row for row in csv_reader ]
2919
30- table = []
3120for benchmark , baseline in zip (table_benchmark , table_baseline ):
3221 assert (benchmark [0 ] == baseline [0 ] and benchmark [2 :4 ] == baseline [2 :4 ])
3322 name = benchmark [0 ]
3423 time = benchmark [1 ]
3524 d = float (baseline [1 ]) - float (benchmark [1 ])
36- difference = html_inline (d )
37- percent = html_inline (100 * d / float (baseline [1 ]))
25+ emoji = ':red_circle:' if 0 < d else ':green_circle:'
26+ difference = pretty (d )
27+ percent = pretty (100 * d / float (baseline [1 ]))
3828 count = benchmark [2 ]
3929 events = benchmark [3 ]
40- table .append ([name , time , difference , percent , count , events ])
30+ table .append ([name , time , emoji , difference , percent , count , events ])
4131
42- header = ["name" , "time" , "difference" , "percent" , "count" , "events" ]
32+ header = ["name" , "time" , "" , " difference" , "percent" , "count" , "events" ]
4333print (tab .tabulate (table , header , tablefmt = "github" ))
0 commit comments