Skip to content

Commit 0f8ed0b

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

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

.github/scripts/csv_to_md.py

Lines changed: 6 additions & 15 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)
@@ -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"]
4334
print(tab.tabulate(table, header, tablefmt="github"))

0 commit comments

Comments
 (0)