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 )
@@ -33,11 +23,12 @@ def html_inline(x):
3323 name = benchmark [0 ]
3424 time = benchmark [1 ]
3525 d = float (baseline [1 ]) - float (benchmark [1 ])
36- difference = html_inline (d )
37- percent = html_inline (100 * d / float (baseline [1 ]))
26+ emoji = ':red_circle:' if 0 < d else ':green_circle:'
27+ difference = pretty (d )
28+ percent = pretty (100 * d / float (baseline [1 ]))
3829 count = benchmark [2 ]
3930 events = benchmark [3 ]
40- table .append ([name , time , difference , percent , count , events ])
31+ table .append ([name , time , emoji , difference , percent , count , events ])
4132
42- header = ["name" , "time" , "difference" , "percent" , "count" , "events" ]
33+ header = ["name" , "time" , "" , " difference" , "percent" , "count" , "events" ]
4334print (tab .tabulate (table , header , tablefmt = "github" ))
0 commit comments