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
|
#!/usr/bin/python
from matplotlib import pyplot as plt
files = [
('local', 'couchdb-json', 'b'),
('local', 'bigcouch-json', 'r'),
('local', 'couchdb-multipart', 'g'),
('local', 'bigcouch-multipart', 'm'),
]
# config the plot
plt.xlabel('time')
plt.ylabel('memory usage')
plt.title('bigcouch versus couch memory usage')
for fi in files:
machine = fi[0]
database = fi[1]
color = fi[2]
filename = '%s-%s.txt' % (machine, database)
x = []
y = []
xmax = None
xmin = None
ymax = None
ymin = None
# read data from file
with open(filename, 'r') as f:
line = f.readline()
while line is not None:
time, mem = tuple(line.strip().split(' '))
mem = float(mem) / (10**9)
x.append(float(time))
y.append(mem)
if ymax == None or mem > ymax:
ymax = mem
xmax = time
if ymin == None or mem < ymin:
ymin = mem
xmin = time
line = f.readline()
if line == '':
break
kwargs = {
'linewidth': 1.0,
'linestyle': '-',
# 'marker': '.',
'color': color,
}
plt.plot(x, y, label=database, **kwargs)
#plt.axes().get_xaxis().set_ticks(x)
#plt.axes().get_xaxis().set_ticklabels(x)
# annotate max and min values
#plt.axes().annotate("%.2f GB" % ymax, xy=(xmax, ymax))
#plt.axes().annotate("%.2f GB" % ymin, xy=(xmin, ymin))
plt.grid()
plt.legend()
plt.show()
|