-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot11.py
71 lines (56 loc) · 3.02 KB
/
plot11.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
67
68
69
70
71
import matplotlib.pyplot as plt
import numpy as np
import data
for iter in [400, 10]:
plt.rcParams.update({"font.size": 22})
fig, ax = plt.subplots(figsize=(12, 5.5))
time_data = {runtime: data.time_data[runtime] for runtime in data.time_data}
time_data = {
runtime: time_data[runtime]
for runtime in sorted(time_data, key=lambda x: time_data[x][iter])
}
times = [time_data[runtime][iter] for runtime in time_data]
runtimes = list(time_data.keys())
width = 0.4
colors = ["#2d85f0" if runtime != "crun+wamr" else "#ed755c" for runtime in runtimes]
alpha = [1 if "python" not in runtime else 0.5 for runtime in runtimes]
for i, runtime in enumerate(runtimes):
if "wamr" not in runtime:
if time_data[runtime][iter] != 0:
print(
f"{iter}: wamr uses {time_data['crun+wamr'][iter]} s, while {runtime} uses {time_data[runtime][iter]} s\n"
f"{iter}: wamr uses {round((1 - time_data['crun+wamr'][iter] / time_data[runtime][iter]) * 100, 2)}% less time than {runtime}"
)
print("__________________________________________________________")
for i, runtime in enumerate(runtimes):
if "containerd-shim-wasmedge" not in runtime:
if time_data[runtime][iter] != 0:
print(
f"{iter}: containerd-shim-wasmedge uses {time_data['containerd-shim-wasmedge'][iter]} s, while {runtime} uses {time_data[runtime][iter]} s\n"
f"{iter}: containerd-shim-wasmedge uses {round((1 - time_data['containerd-shim-wasmedge'][iter] / time_data[runtime][iter]) * 100, 2)}% less time than {runtime}"
)
print("__________________________________________________________")
for i, runtime in enumerate(runtimes):
if "crun+wasmtime" not in runtime:
if time_data[runtime][iter] != 0:
print(
f"{iter}: crun+wasmtime uses {time_data['crun+wasmtime'][iter]} s, while {runtime} uses {time_data[runtime][iter]} s\n"
f"{iter}: crun+wasmtime uses {round((1 - time_data['crun+wasmtime'][iter] / time_data[runtime][iter]) * 100, 2)}% less time than {runtime}"
)
print("__________________________________________________________")
avg = sum(times) / len(times)
print("avg time for", iter, "pods:", avg, "s")
y = np.arange(len(runtimes))
for i, runtime in enumerate(runtimes):
ax.barh(runtime, times[i], color=colors[i], label="kubectl top", alpha=alpha[i])
ax.set_xlabel("Time to Start All Containers (s)")
# ax.set_title('Startup Time: crun + WAMR vs Current Sate-of-Art (' + str(iter) + ' pods)')
if iter == 10:
ax.set_xlim(xmax=4.5)
ax.xaxis.set_major_locator(plt.MultipleLocator(1))
else:
ax.set_xlim(xmax=185)
ax.xaxis.set_major_locator(plt.MultipleLocator(25))
# fig.set_size_inches(13.5, 6)
plt.tight_layout(pad=0)
plt.savefig("plot11_crun_" + str(iter) + ".pdf")