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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
import json
import re
import sys
import matplotlib.gridspec as gridspec
from matplotlib.pyplot import *
regexes = {
'stddev': '^Reply rate.*stddev ([0-9.]+)',
'errors': '^Errors: total ([0-9.]+)',
'reply_time': '^Reply time.* response ([0-9.]+)',
'conn_count': '.*--num-conns=([0-9.]+)',
'call_count': '.*--num-calls=([0-9.]+)',
}
regexes = dict(
[(name, re.compile(pat)) for (name, pat) in regexes.items()])
def parse_output(output):
data = {}
for line in output.splitlines():
for name, regex in regexes.items():
match = regex.match(line)
if match:
data[name] = float(match.group(1))
return data
size_requested_actual = {}
max_x = 0
import optparse
parser = optparse.OptionParser()
parser.add_option('-i', action='store')
parser.add_option('-x', action='store')
parser.add_option('-o', action='store', default="plot.png")
opt, args = parser.parse_args()
for fname in args:
data = json.load(open(fname))
results = data['test_runs'][0]['test_results']
for r in results:
if r['result'] == 'skip':
continue
tcid = r['test_case_id']
parts = tcid.split('-')
requested = int(parts[1])
size = int(parts[0][:-1])
del parts[1]
name = '-'.join(parts)
if opt.i and opt.i not in name:
continue
if opt.x and opt.x in name:
continue
max_x = max(max_x, requested)
actual = r['measurement']
ra = size_requested_actual.setdefault(name, [(0, 0, 0, 0, 0, 0, 'pass', 0, size)])
errors = 0
resptimes = []
requests = 0
server_load = float(r['attributes'].get('server01-load', '0.0').strip())
if not server_load:
server_load = float(r['attributes'].get('proxy01-load', '0.0').strip())
for attachment in r['attachments']:
stddevs = []
if re.match('httperf-.*\\.txt', attachment['pathname']):
content = attachment['content'].decode('base64')
data = parse_output(content)
stddev = data['stddev']
stddevs.append(stddev)
errors += data['errors']
requests += data['conn_count'] * data['call_count']
resptimes.append(data['reply_time'])
err = 0
if stddevs:
err = sum(stddevs)/len(stddevs)
resptime = 0
if resptimes:
resptime = sum(resptimes)/len(resptimes)
data_rate = actual*size*8/1024
ra.append(
(requested,
actual,
err,
100*errors/requests,
resptime,
server_load,
r['result'],
data_rate,
size))
colors = list('rgbcymrgb')
data = size_requested_actual.items()
if len(data) > 1:
def key(x):
return x[1][0][8]
data.sort(key=key)
figure(figsize=(6,9))
def p(axes, k, v, c, index, e_index=None):
v.sort()
x = [vv[0] for vv in v]
y = [vv[index] for vv in v]
if e_index is not None:
e = [vv[e_index] for vv in v]
else:
e = None
fmt = c + '-'
axes.set_xlim([0, max_x])
axes.errorbar(x=x, y=y, fmt=fmt, label=k, yerr=e)
fmt = c + 'o'
x = [vv[0] for vv in v if vv[6] == 'pass']
y = [vv[index] for vv in v if vv[6] == 'pass']
axes.errorbar(x=x, y=y, fmt=fmt)
fmt = 'rx'
x = [vv[0] for vv in v if vv[6] == 'fail']
y = [vv[index] for vv in v if vv[6] == 'fail']
axes.errorbar(x=x, y=y, fmt=fmt, ms=10, mew=4)
kws = []
subplots_adjust(hspace=0.001)
gs = gridspec.GridSpec(5, 1, height_ratios=[3, 1, 1, 1, 1])
p1 = subplot(gs[0])
cs = list(colors)
for k, v in data:
p(p1, k.split('-')[0], v, cs.pop(0), 1, 2)
p1.text(0.5, 0.90, "response rate (resp/s)",
horizontalalignment='center',
transform=p1.transAxes)
p1.legend(loc=2)
p1_5 = subplot(gs[1])
cs = list(colors)
for k, v in data:
p(p1_5, k, v, cs.pop(0), 7)
p1_5.text(0.5, 0.80, "data rate (Mb/s)",
horizontalalignment='center',
transform=p1_5.transAxes)
p2 = subplot(gs[2])
cs = list(colors)
for k, v in data:
p(p2, k, v, cs.pop(0), 4)
p2.text(0.5, 0.80, "response time (ms)",
horizontalalignment='center',
transform=p2.transAxes)
p3 = subplot(gs[3])
cs = list(colors)
for k, v in data:
p(p3, k, v, cs.pop(0), 3)
p3.text(0.5, 0.80, "error rate (%)",
horizontalalignment='center',
transform=p3.transAxes)
p4 = subplot(gs[4])
cs = list(colors)
for k, v in data:
p(p4, k, v, cs.pop(0), 5)
p4.text(0.5, 0.80, "server load",
horizontalalignment='center',
transform=p4.transAxes)
xticklabels = p1.get_xticklabels() + p2.get_xticklabels() + p3.get_xticklabels()
setp(xticklabels, visible=False)
savefig(opt.o)
|