-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.py
More file actions
executable file
·71 lines (48 loc) · 1.37 KB
/
table.py
File metadata and controls
executable file
·71 lines (48 loc) · 1.37 KB
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
#!/usr/bin/python
import gzip
import cPickle
import os
def collect_summary(summary, res):
for (m, r) in summary.iteritems():
mean = (0.0 + sum(r)) / len(r)
if m not in res:
res[m] = []
res[m].append(mean)
def collect_all_summaries(summarydir):
res = {}
benchnames = []
for d in os.listdir(summarydir):
benchnames.append(d)
fname = os.path.join(summarydir, d, 'summary')
summaryf = gzip.GzipFile(fname, 'rb')
summary = cPickle.load(summaryf)
summaryf.close()
collect_summary(summary, res)
return (benchnames, res)
def print_table(benchnames, res, tablef):
tablef.write(r"\begin{tabular}{l|")
for b in benchnames:
tablef.write("|c")
tablef.write("}\n")
for b in benchnames:
tablef.write("& %s" % b)
tablef.write(r"\\")
tablef.write("\n")
tablef.write("\\hline\\hline\n")
for (name, stats) in res.iteritems():
tablef.write(name.replace('_', ' '))
for s in stats:
tablef.write("& %.02f" % (s * 100))
tablef.write(r"\\")
tablef.write("\n")
tablef.write("\end{tabular}")
def make_table(summarydir, tablename):
(benchnames, res) = collect_all_summaries(summarydir)
tablef = open(tablename, 'w')
print_table(benchnames, res, tablef)
tablef.close()
if __name__ == '__main__':
import sys
summarydir = sys.argv[1]
tablename = sys.argv[2]
make_table(summarydir, tablename)