-
Notifications
You must be signed in to change notification settings - Fork 2
/
process-benchmarks-output.py
84 lines (72 loc) · 2.39 KB
/
process-benchmarks-output.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def get_alloc(allocator):
res = []
with open(allocator + "-out.txt") as f:
go = False
command_exited = False
ncores = None
for line in f:
if line.startswith("benchmarking on "):
t = line.split()
assert ncores == None
ncores = t[2]
assert t[3] == "cores."
elif line.startswith("# test "):
assert not go
go = True
elif go:
if line.startswith("Command exited") or line.startswith("Command terminated"):
assert not command_exited
command_exited = True
else:
t = line.split()
if len(t) > 0:
bench = t[0]
assert t[1] == allocator
time = t[2]
assert len(t) == 8 or len(t) == 6 or len(t) == 7
if command_exited:
command_exited = False
res.append((bench, "fail"))
else:
res.append((bench, time))
assert go
assert not command_exited
print("cores for " + allocator + ": " + str(ncores))
return res
def print_table(t):
for (a, b, c) in t:
a1 = " " * (16 - len(a))
b1 = " " * (8 - len(b))
print(a + a1 + b + b1 + c)
def print_latex_table(t):
print("\\begin{tabular}{|l|r|r|}")
print("\\hline")
print("Benchmark & mimalloc & Verus mimalloc \\\\ \\hline")
for (a, b, c) in t:
a1 = " " * (16 - len(a))
b1 = " " * (8 - len(b))
print(a + a1 + "& " + b + " s." + b1 + "& " + c + " s. \\\\ \\hline")
print("\\end{tabular}")
vmi = get_alloc("vmi")
mi = get_alloc("mi")
table = [("bench", "mi", "vmi")]
for (a, b) in zip(mi, vmi):
assert a[0] == b[0]
table.append((a[0], a[1], b[1]))
print_table(table)
def float_to_string(f):
f = float(f)
if f < 1.0:
return "%.2f" % f
else:
return "%.1f\\invizero" % f
latex_table = []
for (a, b) in zip(mi, vmi):
assert a[0] == b[0]
if b[1] != 'fail':
assert a[1] != 'fail'
x = float_to_string(a[1])
y = float_to_string(b[1])
latex_table.append((a[0], x, y))
print("")
print_latex_table(latex_table)