mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-07 15:43:07 +00:00
refactor: draw_plots
This commit is contained in:
parent
82bb2019c3
commit
26c54c8d2f
@ -49,82 +49,48 @@ def bulk_run():
|
|||||||
|
|
||||||
df = pd.DataFrame(results)
|
df = pd.DataFrame(results)
|
||||||
df.to_csv(f"{datetime.now().replace(microsecond=0).isoformat()}.csv", index=False)
|
df.to_csv(f"{datetime.now().replace(microsecond=0).isoformat()}.csv", index=False)
|
||||||
plot(df)
|
draw_plots(df)
|
||||||
|
|
||||||
|
|
||||||
def load_and_plot():
|
def load_and_plot():
|
||||||
# with skipping the header
|
# with skipping the header
|
||||||
df = pd.read_csv("2024-05-25T23:16:39.csv")
|
df = pd.read_csv("2024-05-25T23:16:39.csv")
|
||||||
print(df)
|
print(df)
|
||||||
plot(df)
|
draw_plots(df)
|
||||||
|
|
||||||
|
|
||||||
def plot(df: pd.DataFrame):
|
def draw_plots(df: pd.DataFrame):
|
||||||
egress_max_df = df.pivot(index='num_nodes', columns='config', values='egress_max')
|
max_ylim = draw_plot(df, "num_nodes", "config", "egress_max", "Egress Bandwidth (Max)",
|
||||||
|
"Number of Nodes", "Max Bandwidth (KiB/s)")
|
||||||
|
draw_plot(df, "num_nodes", "config", "egress_mean", "Egress Bandwidth (Mean)",
|
||||||
|
"Number of Nodes", "Mean Bandwidth (KiB/s)", max_ylim)
|
||||||
|
|
||||||
|
max_ylim = draw_plot(df, "num_nodes", "config", "ingress_max", "Ingress Bandwidth (Max)",
|
||||||
|
"Number of Nodes", "Max Bandwidth (KiB/s)")
|
||||||
|
draw_plot(df, "num_nodes", "config", "ingress_mean", "Ingress Bandwidth (Mean)",
|
||||||
|
"Number of Nodes", "Mean Bandwidth (KiB/s)", max_ylim)
|
||||||
|
|
||||||
|
|
||||||
|
def draw_plot(df: pd.DataFrame, index: str, column: str, value: str, title: str, xlabel: str, ylabel: str,
|
||||||
|
ylim: float = None) -> float:
|
||||||
|
df_pivot = df.pivot(index=index, columns=column, values=value)
|
||||||
plt.figure(figsize=(12, 6))
|
plt.figure(figsize=(12, 6))
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
for config in egress_max_df.columns:
|
for i, config in enumerate(df_pivot.columns):
|
||||||
num_mix_layers = int(config.split(":")[1].strip())
|
marker = MARKERS[NUM_MIX_LAYERS_SET.index(int(config.split(":")[1].strip()))]
|
||||||
ax.plot(egress_max_df.index, egress_max_df[config], label=config,
|
ax.plot(df_pivot.index, df_pivot[config], label=config, marker=marker)
|
||||||
marker=MARKERS[NUM_MIX_LAYERS_SET.index(num_mix_layers)])
|
plt.title(title)
|
||||||
plt.title("Egress Bandwidth (Max)")
|
plt.xlabel(xlabel)
|
||||||
plt.xlabel("Number of Nodes")
|
plt.ylabel(ylabel)
|
||||||
plt.ylabel("Max Bandwidth (KiB/s)")
|
|
||||||
plt.legend(title="mode: layers: cover", loc="upper left")
|
plt.legend(title="mode: layers: cover", loc="upper left")
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
|
if ylim is not None:
|
||||||
|
ax.set_ylim(ylim)
|
||||||
plt.show()
|
plt.show()
|
||||||
ingress_max_y_lim = ax.get_ylim()
|
return ax.get_ylim()
|
||||||
|
|
||||||
egress_mean_df = df.pivot(index='num_nodes', columns='config', values='egress_mean')
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
fig, ax = plt.subplots()
|
|
||||||
for config in egress_mean_df.columns:
|
|
||||||
num_mix_layers = int(config.split(":")[1].strip())
|
|
||||||
ax.plot(egress_mean_df.index, egress_mean_df[config], label=config,
|
|
||||||
marker=MARKERS[NUM_MIX_LAYERS_SET.index(num_mix_layers)])
|
|
||||||
plt.title("Egress Bandwidth (Mean)")
|
|
||||||
plt.xlabel("Number of Nodes")
|
|
||||||
plt.ylabel("Mean Bandwidth (KiB/s)")
|
|
||||||
plt.legend(title="mode: layers: cover", loc="upper left")
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.grid(True)
|
|
||||||
ax.set_ylim(ingress_max_y_lim)
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
ingress_max_df = df.pivot(index='num_nodes', columns='config', values='ingress_max')
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
fig, ax = plt.subplots()
|
|
||||||
for config in ingress_max_df.columns:
|
|
||||||
num_mix_layers = int(config.split(":")[1].strip())
|
|
||||||
ax.plot(ingress_max_df.index, ingress_max_df[config], label=config,
|
|
||||||
marker=MARKERS[NUM_MIX_LAYERS_SET.index(num_mix_layers)])
|
|
||||||
plt.title("Ingress Bandwidth (Max)")
|
|
||||||
plt.xlabel("Number of Nodes")
|
|
||||||
plt.ylabel("Max Bandwidth (KiB/s)")
|
|
||||||
plt.legend(title="mode: layers: cover", loc="upper left")
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.grid(True)
|
|
||||||
plt.show()
|
|
||||||
ingress_max_y_lim = ax.get_ylim()
|
|
||||||
|
|
||||||
ingress_mean_df = df.pivot(index='num_nodes', columns='config', values='ingress_mean')
|
|
||||||
plt.figure(figsize=(12, 6))
|
|
||||||
fig, ax = plt.subplots()
|
|
||||||
for config in ingress_mean_df.columns:
|
|
||||||
num_mix_layers = int(config.split(":")[1].strip())
|
|
||||||
ax.plot(ingress_mean_df.index, ingress_mean_df[config], label=config,
|
|
||||||
marker=MARKERS[NUM_MIX_LAYERS_SET.index(num_mix_layers)])
|
|
||||||
plt.title("Ingress Bandwidth (Mean)")
|
|
||||||
plt.xlabel("Number of Nodes")
|
|
||||||
plt.ylabel("Mean Bandwidth (KiB/s)")
|
|
||||||
plt.legend(title="mode: layers: cover", loc="upper left")
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.grid(True)
|
|
||||||
ax.set_ylim(ingress_max_y_lim)
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
bulk_run()
|
# bulk_run()
|
||||||
# load_and_plot()
|
load_and_plot()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user