-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot12.py
90 lines (73 loc) · 2.94 KB
/
plot12.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import matplotlib.pyplot as plt
import numpy as np
import data
if True:
plt.rcParams.update({"font.size": 22})
fig, ax = plt.subplots(figsize=(12, 5.5))
memory_kubectl = data.memory_data["kubectl"]
memory_os = data.memory_data["os"]
memory_kubectl = {
runtime: [
sum(memory_kubectl[runtime][i] for i in [10, 100, 400])
/ sum(1 if memory_kubectl[runtime][i] != 0 else 0 for i in [10, 100, 400])
]
for runtime in memory_kubectl
}
memory_os = {
runtime: [
sum(memory_os[runtime][i] for i in [10, 100, 400])
/ sum(1 if memory_os[runtime][i] != 0 else 0 for i in [10, 100, 400])
]
for runtime in memory_os
}
memory_os = {
runtime: memory_os[runtime] for runtime in sorted(memory_os, key=lambda x: memory_os[x])
}
memory_kubectl = {runtime: memory_kubectl[runtime] for runtime in memory_os}
memory = [memory_kubectl[runtime] for runtime in memory_kubectl]
memory_os = [memory_os[runtime] for runtime in memory_os]
runtimes = list(memory_kubectl.keys())
width = 0.4
y = np.arange(len(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:
print(
f"kubectl: wamr uses {memory[0][0]} MB of memory, while {runtime} uses {memory[i][0]} MB of memory\n"
f"kubectl: wamr uses {round((1 - memory[0][0] / memory[i][0]) * 100, 2)}% less memory than {runtime}\n"
f"OS: wamr uses {memory_os[0]} MB of memory, while {runtime} uses {memory_os[i]} MB of memory\n"
f"OS: wamr uses {round((1 - memory_os[0][0] / memory_os[i][0]) * 100, 2)}% less memory than {runtime}"
)
print("__________________________________________________________")
for i, runtime in enumerate(runtimes):
alpha_value = alpha[i]
ax.barh(
y[i] + width / 2,
memory_os[i],
width * 0.95,
color="#ed755c",
label="free command" if i == 0 else "",
alpha=alpha_value,
)
ax.barh(
y[i] - width / 2,
memory[i],
width * 0.95,
color="#2d85f0",
label="kubectl top" if i == 0 else "",
alpha=alpha_value,
)
ax.set_yticks(y)
ytick_labels = ax.set_yticklabels(runtimes)
for ytick_label in ytick_labels:
if "wamr" in ytick_label.get_text():
ytick_label.set_color("green")
ax.legend(title="Metrics source:")
ax.set_xlabel("Average Memory Used per Pod (MB)")
ax.set_ylabel("Runtime Configuration Used")
# ax.set_title("Memory Usage: crun + WAMR vs Current Sate-of-Art")
ax.set_xlim(xmax=50)
ax.xaxis.set_major_locator(plt.MultipleLocator(10))
# fig.set_size_inches(13.5, 6)
plt.tight_layout(pad=0)
plt.savefig("plot12_crun_avg.pdf")