-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdropped_graphs.py
66 lines (54 loc) · 2.09 KB
/
dropped_graphs.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
import matplotlib.pyplot as plt
from benchmark.controller import Controller
from benchmark.satellite import MockSatelliteGroup as SatelliteGroup
import argparse
from os import path, makedirs
from benchmark.utils import PROJECT_DIR
DATA_FILE = path.join(PROJECT_DIR, "graphs/raw_data.txt")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'client',
help='Name of the client to use in these tests.')
args = parser.parse_args()
# two charts stacked on top of eachother, sharing the x axis
fig, (cpu_ax, dropped_ax) = plt.subplots(2, 1, sharex='col')
makedirs(path.join(PROJECT_DIR, "graphs"), exist_ok=True)
sps_list = []
cpu_list = []
dropped_list = []
with SatelliteGroup('typical') as satellites:
with Controller(args.client) as controller:
for sps in [500, 1000, 5000, 20000, 50000, 100000]:
result = controller.benchmark(
trace=True,
satellites=satellites,
spans_per_second=sps,
runtime=10,
no_timeout=True
)
print(result)
dropped_list.append(
result.dropped_spans / result.spans_sent * 100)
cpu_list.append(result.cpu_usage * 100)
sps_list.append(result.spans_per_second)
# save all raw data from test
with open(DATA_FILE, 'a+') as file:
for i in range(len(dropped_list)):
file.write("{} {} {}\n".format(
sps_list[i],
cpu_list[i],
dropped_list[i],
))
dropped_ax.plot(sps_list, dropped_list)
dropped_ax.set(
xlabel="Spans per second",
ylabel="Percent spans dropped",
title=f'{controller.client_name.title()} Spans Dropped')
cpu_ax.plot(sps_list, cpu_list)
cpu_ax.set(
ylabel="Percent CPU usage",
title=f'{controller.client_name.title()} CPU Usage')
fig.savefig(path.join(
PROJECT_DIR,
f'graphs/{controller.client_name}_sps_vs_dropped.png'))