2024-02-15 14:09:38 +00:00
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import scienceplots
|
|
|
|
import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
from analyze import load
|
|
|
|
|
|
|
|
latencies = pd.DataFrame({
|
2024-03-06 12:12:39 +00:00
|
|
|
"2 KB": load("raw/paper_latency_2kb_v2.txt", "arrival_diff="),
|
|
|
|
"25 KB": load("raw/paper_latency_25kb_v2.txt", "arrival_diff="),
|
|
|
|
"100 KB": load("raw/paper_latency_100kb_v2.txt", "arrival_diff="),
|
|
|
|
"500 KB": load("raw/paper_latency_500kb_v2.txt", "arrival_diff=")})
|
2024-02-15 14:09:38 +00:00
|
|
|
|
|
|
|
num_bins = 50
|
|
|
|
|
2024-03-04 14:07:35 +00:00
|
|
|
# Best (1 hop) and worst (4 hops) latencies in ms
|
|
|
|
# See Table 2 from paper
|
|
|
|
multi_host_simulations = {
|
2024-03-06 12:12:39 +00:00
|
|
|
# msg_size: min/max
|
|
|
|
"2 KB": [280, 498],
|
|
|
|
"25 KB": [349, 931],
|
|
|
|
"100 KB": [350, 1781],
|
|
|
|
"500 KB": [539, 3141],
|
2024-03-04 14:07:35 +00:00
|
|
|
}
|
2024-02-15 14:09:38 +00:00
|
|
|
|
|
|
|
with plt.style.context(['science', 'ieee']):
|
|
|
|
fig, ax = plt.subplots(2, 2)
|
|
|
|
possitions = [
|
2024-03-06 12:12:39 +00:00
|
|
|
("2 KB", ax[0][0]),
|
|
|
|
("25 KB", ax[0][1]),
|
|
|
|
("100 KB", ax[1][0]),
|
|
|
|
("500 KB", ax[1][1])
|
2024-02-15 14:09:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
for (size, pos) in possitions:
|
2024-03-04 14:07:35 +00:00
|
|
|
# Plot single host results
|
2024-03-06 12:12:39 +00:00
|
|
|
latencies.hist(size, bins=num_bins, ax=pos, density=True, label="Single-host")
|
2024-03-04 14:07:35 +00:00
|
|
|
|
|
|
|
# Plot multi host results
|
2024-03-06 12:12:39 +00:00
|
|
|
pos.axvline(x=multi_host_simulations[size][0], color='red', linestyle='--', label="Multi-host")
|
2024-03-04 14:07:35 +00:00
|
|
|
pos.axvline(x=multi_host_simulations[size][1], color='red', linestyle='--')
|
|
|
|
|
2024-02-15 14:09:38 +00:00
|
|
|
pos.grid(False)
|
2024-03-06 12:12:39 +00:00
|
|
|
title = ('Message Size = {size}'.format(size=size))
|
2024-03-04 14:07:35 +00:00
|
|
|
pos.set_title(title, fontsize=8)
|
|
|
|
if size == "25kb":
|
|
|
|
pos.legend(fontsize="5", loc="upper left")
|
|
|
|
else:
|
|
|
|
pos.legend(fontsize="5", loc="best")
|
2024-02-15 14:09:38 +00:00
|
|
|
|
2024-03-05 17:50:16 +00:00
|
|
|
ax[0][0].set(ylabel='Message share')
|
2024-03-06 12:12:39 +00:00
|
|
|
ax[1][0].set(xlabel='Latency (ms)', ylabel='Message share')
|
2024-02-15 14:09:38 +00:00
|
|
|
ax[1][1].set(xlabel='Latency (ms)')
|
|
|
|
|
2024-03-04 14:07:35 +00:00
|
|
|
plt.tight_layout(pad=0, w_pad=0, h_pad=0.7)
|
2024-02-15 14:09:38 +00:00
|
|
|
fig.set_size_inches(4, 3)
|
|
|
|
fig.savefig('paper_distribution.svg', dpi=600)
|