-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-memcached_gen_data-time_per_op-cdf.py
More file actions
executable file
·72 lines (48 loc) · 1.61 KB
/
plot-memcached_gen_data-time_per_op-cdf.py
File metadata and controls
executable file
·72 lines (48 loc) · 1.61 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
72
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import re
import itertools
from collections import OrderedDict
from sys import argv, exit
from paperstyle import COLORS, MARKERS, IS_PDF, FIGSIZE, LINE_STYLES, SLIDE_PLOT, HIDDEN
REGEX = r'^DONE [0-9]+ Duration { secs: ([0-9]+), nanos: ([0-9]+) }( [0-9]+)?$'
SCALE = 1E6
UNIT = 'msec'
VALUE_SIZE = 1 << 19
data = OrderedDict()
for arg in argv[1:]:
label, filename = arg.split(":")
data[label] = []
with open(filename, 'r') as f:
for line in f.readlines():
m = re.match(REGEX, line)
if m is None:
print("ERROR: no match for line %s" % line)
#exit(1)
continue
time = int(m.group(1)) * 1E9 + float(m.group(2))
data[label].append(time / SCALE)
plt.figure(1, figsize=FIGSIZE)
colors = itertools.cycle(COLORS)
linestyles = itertools.cycle(LINE_STYLES)
handles = []
for label, xs in data.items():
cdfx = np.sort(xs)
cdfy = np.linspace(0.0, 100.0, len(xs))
ls = '-' if SLIDE_PLOT else next(linestyles)
if label in HIDDEN:
ls = 'None'
label = None
lw = 3 if SLIDE_PLOT else 1
h_plot, = plt.plot(cdfx, cdfy, label = label, linestyle = ls, linewidth=lw, marker = 'None', color = next(colors))
handles.append(h_plot)
plt.legend(handles=handles, loc='upper left')
plt.xscale('log')
plt.ylim((0, 100))
plt.xlabel('Latency of Operations (%s)' % UNIT)
plt.ylabel("% of Operations")
plt.title('')
plt.grid(True)
plt.savefig("/tmp/figure.%s" % ("pdf" if IS_PDF else "png"), bbox_inches="tight")
plt.show()