-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
executable file
·87 lines (76 loc) · 2.33 KB
/
plot.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
85
86
87
#!/usr/bin/env python3
from os import path
import argparse
import subprocess
import re
import json
import os
import resource
import itertools
parser = argparse.ArgumentParser(
description="Generate latency-throughput graphs"
)
parser.add_argument(
"-v",
"--verbose",
help="print commands in addition to running them",
action="store_true",
)
parser.add_argument(
"--outdir",
help="output directory for benchmark results",
required=True,
default=None,
)
global_args = parser.parse_args()
def read_lt_data(infilename):
with open(infilename, 'r') as f:
data = []
for line in f:
data.append(json.loads(line))
return data
def plot_lt(datas):
"""
Assumes data is in format
[ (kvname, numthreads, { 'OPERATION_TYPE': (throughput in ops/sec, latency in us), ... } ), ... ]
"""
# marker = itertools.cycle(('+', '.', 'o', '*'))
# fig = plt.figure()
for data in datas:
# rxs = []
# rys = []
# wxs = []
# wys = []
xys = []
for d in data:
# TODO: look for updates and reads; if any other operation is found, report an error
x = 0.0
y = 0.0
for k, v in d['lts'].items():
if k == 'READ':
x = x + v['thruput']
y = y + v['avg_latency'] / 1000
if k == 'UPDATE':
throw("unimpl")
xys.append((x,y))
with open(data[0]['service'] + '.dat', 'w') as f:
for xy in xys:
print('{0}, {1}'.format(xy[0], xy[1]), file=f)
# if wxs != []:
# plt.plot(wxs, wys, marker = next(marker), label=data[0]['service'] + " puts")
# if rxs != []:
# plt.plot(rxs, rys, marker = next(marker), label=data[0]['service'] + " gets")
# plt.xlabel('Throughput (ops/sec)')
# plt.ylabel('Latency (ms)')
# plt.title(data[0]['service'])
# plt.legend()
# plt.tight_layout()
# fig.savefig('temp.pdf')
def main():
datas = []
# redis_write_data = read_lt_data(path.join(global_args.outdir, 'rediskv_update_closed_lt.jsons'))
memkv_data = read_lt_data(path.join(global_args.outdir, 'memkv_lt.jsons'))
# datas += [redis_write_data, memkv_write_data]
plot_lt([memkv_data])
if __name__=='__main__':
main()