-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot15.py
64 lines (48 loc) · 2.71 KB
/
plot15.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
import matplotlib.pyplot as plt
import numpy as np
import data
for iter in ["kubectl", "os"]:
plt.rcParams.update({"font.size": 22})
fig, ax = plt.subplots(figsize=(12, 5.5))
memory = data.memory_data[iter]
memory = {
runtime: memory[runtime] for runtime in memory if "wamr" in runtime or "python" in runtime
}
memory = {runtime: memory[runtime] for runtime in sorted(memory, key=lambda x: memory[x][10])}
memory_400 = [memory[runtime][400] for runtime in memory]
memory_100 = [memory[runtime][100] for runtime in memory]
memory_10 = [memory[runtime][10] for runtime in memory]
print(iter)
for i, runtime in enumerate(memory):
if "wamr" not in runtime:
print(
f"400: wamr uses {memory['crun+wamr'][400]} MB of memory, while {runtime} uses {memory[runtime][400]} MB of memory\n"
f"400: wamr uses {round((1 - memory['crun+wamr'][400] / memory[runtime][400]) * 100, 2)}% less memory than {runtime}\n"
f"100: wamr uses {memory['crun+wamr'][100]} MB of memory, while {runtime} uses {memory[runtime][100]} MB of memory\n"
f"100: wamr uses {round((1 - memory['crun+wamr'][100] / memory[runtime][100]) * 100, 2)}% less memory than {runtime}\n"
f"10: wamr uses {memory['crun+wamr'][10]} MB of memory, while {runtime} uses {memory[runtime][10]} MB of memory\n"
f"10: wamr uses {round((1 - memory['crun+wamr'][10] / memory[runtime][10]) * 100, 2)}% less memory than {runtime}"
)
print("__________________________________________________________")
runtimes = list(memory.keys())
width = 0.2
x = np.arange(len(runtimes))
ax.bar(x - width, memory_10, width=width * 0.95, color="#2d85f0", label="10 pods")
ax.bar(x, memory_100, width=width * 0.95, color="#ed755c", label="100 pods")
ax.bar(x + width, memory_400, width=width * 0.95, color="#27a145", label="400 pods")
ax.set_xticks(x)
xtick_labels = ax.set_xticklabels(runtimes)
for xtick_label in xtick_labels:
if "wamr" in xtick_label.get_text():
xtick_label.set_color("red")
ax.legend(title="Deployment Size:", ncol=3)
# ax.legend(title="Deployment Size:", loc="upper left", bbox_to_anchor=(1, 1))
ax.set_ylabel("Memory Used per Pod (MB)")
ax.set_xlabel("Runtime Configuration Used", labelpad=15)
name = "kubectl top" if iter == "kubectl" else "free command"
# ax.set_title("Memory Usage: crun + WAMR vs Python (crun and runC) (" + str(name) + ")")
ax.set_ylim(ymax=22)
ax.yaxis.set_major_locator(plt.MultipleLocator(4))
# fig.set_size_inches(13.5, 6)
plt.tight_layout(pad=0)
plt.savefig("plot15_python_" + str(iter) + ".pdf")