-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot13.py
71 lines (54 loc) · 2.88 KB
/
plot13.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 ["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 "shim" in runtime or "wamr" 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:
if memory[runtime][400] != 0:
print(
f"400: {runtime} uses {memory[runtime][400]} MB of memory while wamr uses {memory['crun+wamr'][400]} MB of memory\n"
f"400: {runtime} uses {round((1 - memory[runtime][400] / memory['crun+wamr'][400]) * 100, 2)}% more memory than wamr"
)
print(
f"100: {runtime} uses {memory[runtime][100]} MB of memory while wamr uses {memory['crun+wamr'][100]} MB of memory\n"
f"100: {runtime} uses {round((1 - memory[runtime][100] / memory['crun+wamr'][100]) * 100, 2)}% more memory than wamr\n"
f"10: {runtime} uses {memory[runtime][10]} MB of memory while wamr uses {memory['crun+wamr'][10]} MB of memory\n"
f"10: {runtime} uses {round((1 - memory[runtime][10] / memory['crun+wamr'][10]) * 100, 2)}% more memory than wamr"
)
print("__________________________________________________________")
runtimes = list(memory.keys())
width = 0.22
runtimes = [
runtime.replace("-", "\n", 1) if runtime.count("-") > 1 else runtime for runtime in runtimes
]
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:")
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 Runwasi Shims (" + str(name) + ")")
ax.set_ylim(ymax=60)
ax.yaxis.set_major_locator(plt.MultipleLocator(10))
# plt.setp(ax.get_xticklabels(), rotation=10, ha="right")
# fig.set_size_inches(13.5, 6)
plt.tight_layout(pad=0)
plt.savefig("plot13_shim_" + str(iter) + ".pdf")