-
Notifications
You must be signed in to change notification settings - Fork 80
/
parse_result.py
executable file
·69 lines (53 loc) · 1.88 KB
/
parse_result.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
#! /usr/bin/env python
import sys
import os
import numpy
__author__ = "Jinglei Ren"
__copyright__ = "Copyright (c) 2014 Jinglei Ren"
__email__ = "[email protected]"
def main():
if len(sys.argv) != 2 or sys.argv[1] == '-h':
print "Usage: %s OutputFileName" % sys.argv[0]
print "Statistics (.result file) for each workload " + \
"will be written to the workload directory."
sys.exit(-1)
path = sys.argv[1]
lines = [line.strip().split('\t') for line in open(path)]
results = {}
db_index = set() # db name
tn_index = set() # thread number
for line in lines:
if line[0][0] == '#':
continue
db_name = line[0]
db_index.add(db_name)
dir_name, workload = os.path.split(line[1])
workload = os.path.splitext(workload)[0]
num_threads = int(line[2])
tn_index.add(num_threads)
throughput = float(line[3])
if not results.has_key(workload):
results[workload] = {}
if not results[workload].has_key(db_name):
results[workload][db_name] = {}
if not results[workload][db_name].has_key(num_threads):
results[workload][db_name][num_threads] = []
results[workload][db_name][num_threads].append(throughput)
db_index = sorted(db_index)
tn_index = sorted(tn_index)
for wl in sorted(results.keys()):
out_file = open(os.path.join(dir_name, wl + ".result"), 'w+')
# Prints header
line = "#"
for db in db_index:
line += '\t' + db
out_file.write(line + '\n')
# Prints results
for tn in tn_index:
line = str(tn)
for db in db_index:
data = results[wl][db][tn]
line += '\t' + str(numpy.median(numpy.array(data)))
out_file.write(line + '\n')
if __name__ == '__main__':
main()