forked from ls4154/YCSB-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge_ycsb.py
50 lines (40 loc) · 1.49 KB
/
merge_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
import sys
runs = int(sys.argv[1])
exp_dir = sys.argv[2]
workloads = ["load", "a", "b", "c", "d", "f"]
methods = ["workloadaware", "monkey", "default"]
def aggregate(filename, result, workload_index):
infile = open(filename, "r")
data = infile.readlines()
infile.close()
for i in range(len(data)):
line = data[i].strip()
if line.startswith("Load throughput"):
result[0] += float(line.split(':')[-1].strip())
elif line.startswith("Run throughput"):
result[workload_index] += float(line.split(':')[-1].strip())
break
def output(filename, result):
outfile = open(filename, "w")
header = "workloads"
for m in methods:
header += "," + m
header += "\n"
outfile.write(header)
for i in range(len(workloads)):
line = workloads[i]
for m in methods:
line += "," + str(round(result[m][i],2))
line += "\n"
outfile.write(line)
outfile.close()
total_results = dict()
for i in range(len(methods)):
total_results[methods[i]] = [0 for _ in workloads]
for j in range(1, len(workloads)):
for k in range(1, runs+1):
aggregate(exp_dir + "/run" + str(k) + "/" + methods[i] + "_workload" + workloads[j] + "_ycsb_result.txt", total_results[methods[i]], j)
total_results[methods[i]][0] /= runs*len(workloads)*1.0
for j in range(1, len(workloads)):
total_results[methods[i]][j] /= runs*1.0
output(exp_dir + "/ycsb_agg_exp.txt", total_results)