-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake_table.py
executable file
·57 lines (44 loc) · 1.18 KB
/
make_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/python3
import os
stream = os.popen('bash -c "cargo bench | grep time"')
#stream = os.popen('bash -c "cargo bench rustbus | grep time"')
output = stream.read()
table_lines = []
results = {}
benches = []
def filter_empty(var):
return len(var) != 0
lines = output.split("\n")
for line in lines:
if len(line) == 0:
continue
words = line.split(" ")
words = list(filter(filter_empty, words))
name_split = words[0].split("_")
benchname = name_split[0]
libname = "_".join(name_split[1:])
timings = " ".join(words[2:])
if not benchname in benches:
benches.append(benchname)
if not libname in results:
results[libname] = {}
results[libname][benchname] = timings
for libname in results:
print(libname)
line = "|" + libname + "|"
for bench in benches:
libbenches = results[libname]
if bench in libbenches:
line += libbenches[bench]
line += "|"
table_lines.append(line)
header = "|Library|"
for bench in benches:
header += bench + "|"
print(header)
header = "|-|"
for bench in benches:
header += "-|"
print(header)
for line in table_lines:
print(line)