Skip to content

Commit 4047231

Browse files
Use emojis instead of html
1 parent 4d66aba commit 4047231

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

.github/scripts/csv_to_md.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,7 @@
55
csv_benchmark = sys.argv[1]
66
csv_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

2010
with 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 = []
3120
for 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"]
4333
print(tab.tabulate(table, header, tablefmt="github"))

0 commit comments

Comments
 (0)