Skip to content

Commit 575c777

Browse files
committed
plots
1 parent 76f5a73 commit 575c777

File tree

10 files changed

+487
-50
lines changed

10 files changed

+487
-50
lines changed

bench_all.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ do
1515
wrk -t12 -c400 -d10s http://localhost:8080/?delay=0
1616
wrk -t12 -c400 -d10s http://localhost:8080/?delay=100
1717

18-
for factor in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
18+
for factor in 0 1 2 3 4 5 6 7 8 9 10
1919
do
2020
delay=$(($factor * 100))
2121
echo "benchmark [$delay ms]:"| tee -a ../results.log
@@ -40,3 +40,4 @@ do
4040
done;
4141

4242
cat *-app/*.csv > report.csv
43+
python3 ./generate_plots.py

generate_plots.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env python
2+
import csv
3+
import matplotlib.pyplot as plt
4+
5+
6+
def to_python(s):
7+
if s.endswith('app'):
8+
return s
9+
elif '.' in s:
10+
return float(s)
11+
else:
12+
return int(s)
13+
14+
15+
def load(p):
16+
with open(p, 'r') as f:
17+
report = csv.reader(f)
18+
raw_data = [list(map(to_python, l)) for l in report]
19+
20+
data = {}
21+
for i in raw_data:
22+
title = i[0]
23+
if title not in data:
24+
data[title] = []
25+
data[title].append(i[1:])
26+
return data
27+
28+
29+
def plot(data, ax, y_index, x_index=0):
30+
for label, rows in data.items():
31+
x = [i[x_index] for i in rows]
32+
y = [i[y_index] for i in rows]
33+
ax.scatter(x, y, label=label)
34+
35+
36+
def plots(plots_desc, data):
37+
for p in plots_desc:
38+
title, x_desc, y_desc, prepare, fname = p
39+
x_label, x_index = x_desc
40+
y_label, y_index = y_desc
41+
fig, ax = plt.subplots()
42+
prepare(ax)
43+
ax.set_title(title)
44+
plot(data, ax, y_index, x_index)
45+
ax.legend()
46+
ax.set_xlabel(x_label)
47+
ax.set_ylabel(y_label)
48+
fig.savefig('plots/' + fname)
49+
50+
51+
def main():
52+
plots(
53+
[
54+
[
55+
"Requests/sec",
56+
["delay [ms]", 0],
57+
["req/s", 1],
58+
lambda ax: ax.set_yscale("log", nonposx='clip'),
59+
"requests_per_sec.png"
60+
],
61+
[
62+
"Transfer",
63+
["delay [ms]", 0],
64+
["KB/s", 2],
65+
lambda ax: ax.set_yscale("log", nonposx='clip'),
66+
"transfer.png"
67+
],
68+
[
69+
"Latency",
70+
["delay [ms]", 0],
71+
["KB/s", 3],
72+
lambda ax: ax,
73+
"latency.png"
74+
],
75+
[
76+
"Timeouts",
77+
["delay [ms]", 0],
78+
["errors", 5],
79+
lambda ax: ax,
80+
"timeouts.png"
81+
],
82+
[
83+
"All Errors",
84+
["delay [ms]", 0],
85+
["errors", 6],
86+
lambda ax: ax,
87+
"all_errors.png"
88+
]
89+
],
90+
load('./report.csv')
91+
)
92+
93+
94+
if __name__ == '__main__':
95+
main()

0 commit comments

Comments
 (0)