-
Notifications
You must be signed in to change notification settings - Fork 7
/
parse_ycsb.py
executable file
·65 lines (56 loc) · 1.51 KB
/
parse_ycsb.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
#!/usr/bin/env python3
import sys
import os
import re
import math
load_ser = "Throughput: load"
run_ser = "Throughput: run"
worka = "workloada,"
workb = "workloadb,"
workc = "workloadc,"
load = []
arun = []
brun = []
crun = []
# Parse driver output
fname = sys.argv[1]
def ser_app(line, ser, num, idx):
x = re.search(ser, line)
if x:
l = line.split(' ')
n = l[idx].strip()
n = float(n) * 1000000
num.append(n)
with open(fname) as f:
line = f.readline()
while line != "":
if (line.split(' ')[1] == worka):
line = f.readline()
# ser_app(line, load_ser, load, 2)
line = f.readline()
ser_app(line, run_ser, arun, 2)
elif (line.split(' ')[1] == workb):
line = f.readline()
# ser_app(line, load_ser, load, 2)
line = f.readline()
ser_app(line, run_ser, brun, 2)
elif (line.split(' ')[1] == workc):
line = f.readline()
ser_app(line, load_ser, load, 2)
line = f.readline()
ser_app(line, run_ser, crun, 2)
line = f.readline()
# print(load)
# print(arun)
# print(brun)
# print(crun)
# Print output file
opfname = sys.argv[2]
opf = open(opfname, "w")
opf.write("threads\t\tload\t\ta\t\tb\t\tc\n")
idx = 0
for l, a, b, c in zip(load, arun, brun, crun):
thr = int(math.pow(2, idx))
opf.write(str(thr) + "\t\t" + str(l) + "\t\t" + str(a) + "\t\t" + str(b) + "\t\t" + str(c) + "\n")
idx = idx+1
opf.close()