-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmemory_graphs.py
53 lines (43 loc) · 1.81 KB
/
memory_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
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
GRAPHS_DIR = path.join(PROJECT_DIR, 'graphs')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'client',
help='Name of the client to use in these tests.')
args = parser.parse_args()
fig, ax = plt.subplots()
makedirs(path.join(PROJECT_DIR, "graphs"), exist_ok=True)
with SatelliteGroup('typical') as satellites:
with Controller(args.client) as controller:
for sps in [100, 500, 1000, 2000]:
result = controller.benchmark(
trace=True,
spans_per_second=sps,
runtime=50,
)
print(result)
runtime_list = list(range(1, len(result.memory_list) + 1))
memory_list = [m * 2**-20 for m in result.memory_list]
ax.plot(runtime_list, memory_list, label=f'{sps} spans / sec')
# save all raw data from test
filepath = path.join(GRAPHS_DIR, f'raw_data_{sps}sps.txt')
with open(filepath, 'a+') as file:
for i in range(len(runtime_list)):
file.write("{} {}\n".format(
runtime_list[i],
memory_list[i]
))
ax.set(
xlabel="Seconds program runtime",
ylabel="Program memory footprint (MB)")
ax.set_title(f'{controller.client_name.title()} Memory Use Over Time')
ax.legend()
fig.savefig(path.join(
PROJECT_DIR,
f'graphs/{controller.client_name}_runtime_vs_memory.png'))