-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_latency_boxplot.py
More file actions
102 lines (80 loc) · 3.8 KB
/
create_latency_boxplot.py
File metadata and controls
102 lines (80 loc) · 3.8 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
import matplotlib.pyplot as plt
import numpy as np
with open("elixir/latency_bench_results/latency.txt") as f:
for line in f:
elixirdata = line.split(",")
elixirdata = [int(x) / 1000 for x in elixirdata]
with open("golang/latency_bench_results/latency.txt") as f:
godata = f.read().split(",")
godata = [int(x) / 1000 for x in godata]
with open("akka/latency_bench_results/latency.txt") as f:
akkadata = f.read().split(",")
akkadata = [int(x) / 1000 for x in akkadata]
fig, ax = plt.subplots()
box = ax.boxplot([elixirdata, akkadata, godata],
tick_labels=['Elixir', 'Akka', 'Ergo'],
showfliers=False,
showmeans=True,
meanline=True,
meanprops=dict(linewidth=2))
# Calculate and print the Interquartile Range (IQR)
iqr_elixir = np.percentile(elixirdata, 75) - np.percentile(elixirdata, 25)
iqr_golang = np.percentile(godata, 75) - np.percentile(godata, 25)
iqr_akka = np.percentile(akkadata, 75) - np.percentile(akkadata, 25)
print(f'IQR for Elixir: {iqr_elixir}')
print(f'IQR for Golang: {iqr_golang}')
print(f'IQR for Akka: {iqr_akka}')
# Calculate and print the farthest upper and lower outliers
def find_farthest_outliers(data):
q1 = np.percentile(data, 25)
q3 = np.percentile(data, 75)
iqr = q3 - q1
lower_bound = q1 - 1.5 * iqr
upper_bound = q3 + 1.5 * iqr
lower_outliers = [x for x in data if x < lower_bound]
upper_outliers = [x for x in data if x > upper_bound]
farthest_lower_outlier = min(lower_outliers) if lower_outliers else None
farthest_upper_outlier = max(upper_outliers) if upper_outliers else None
return farthest_lower_outlier, farthest_upper_outlier
farthest_lower_elixir, farthest_upper_elixir = find_farthest_outliers(elixirdata)
farthest_lower_golang, farthest_upper_golang = find_farthest_outliers(godata)
farthest_lower_akka, farthest_upper_akka = find_farthest_outliers(akkadata)
print(f'Farthest lower outlier for Elixir: {farthest_lower_elixir}')
print(f'Farthest upper outlier for Elixir: {farthest_upper_elixir}')
print(f'Farthest lower outlier for Golang: {farthest_lower_golang}')
print(f'Farthest upper outlier for Golang: {farthest_upper_golang}')
print(f'Farthest lower outlier for Akka: {farthest_lower_akka}')
print(f'Farthest upper outlier for Akka: {farthest_upper_akka}')
means = [np.mean(elixirdata), np.mean(akkadata), np.mean(godata)]
for i, mean in enumerate(means, start=1):
ax.text(i, mean, f'{mean:.2f}', ha='center', va='bottom', color='green')
ax.set_ylabel('Latency (microseconds)')
ax.set_title('Actor Spawn Latency')
mean_patch = plt.Line2D([], [], color='green', label='Mean', linestyle='dashed', linewidth=1)
median_patch = plt.Line2D([], [], color='orange', label='Median', linewidth=1)
mean_patch = plt.Line2D([], [], color='green', label='Mean in Microseconds', linestyle='dashed', linewidth=1)
ax.legend(handles=[mean_patch, median_patch])
plt.grid(True)
plt.tight_layout(pad=0)
filename = "images/latency/latency_boxplot"
# plt.savefig(f'{filename}.svg')
# plt.savefig(f'{filename}.png', dpi=300)
plt.savefig(f'{filename}.pdf')
fig, ax = plt.subplots()
x_elixir = range(1, len(elixirdata) + 1)
x_golang = range(1, len(godata) + 1)
x_akka = range(1, len(akkadata) + 1)
# Plot lines for each framework
# ax.plot(x_elixir, elixirdata, label='Elixir', color='blue', linewidth=1)
ax.plot(x_golang, godata, label='Ergo', color='red', linewidth=1)
# ax.plot(x_akka, akkadata, label='Akka', color='green', linewidth=1)
ax.set_xlabel('Spawn Index')
ax.set_ylabel('Latency (microseconds)')
ax.set_title('Latency Over Time for Actor Spawns')
ax.legend()
filename_line = "images/latency/latency_linechart"
plt.grid(True)
plt.tight_layout(pad=0)
# plt.savefig(f'{filename_line}.svg')
# plt.savefig(f'{filename_line}.png', dpi=300)
plt.savefig(f'{filename_line}.pdf')