| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #!/usr/bin/env python3
- """
- Compares DEVStone benchmark results from multiple DEVS variants
- (Classic, Parallel, Dynamic Structure, etc.).
- Each CSV must contain:
- model_type, depth, width, run, creation_time, setup_time, simulation_time
- Produces:
- - Plots of scalability (depth/width)
- - Overhead composition
- - Speedup ratios
- - A summary CSV table with average speedups
- """
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- from pathlib import Path
- # === CONFIGURATION ===
- FILES = {
- # "Classic": "./Results-PyPDEVS/DEVSTONE-classic.csv",
- "Parallel": "./Results-PyPDEVS/DEVSTONE.csv",
- # "Minimal": "./Results-PyPDEVS/DEVSTONE-minimal.csv",
- "Dynamic Structure": "./Results-PyPDEVS/DEVSTONE-dynamic.csv",
- # "DS-C": "./Results-PyPDEVS/DEVSTONE-classic-dynamic.csv",
- }
- OUTPUT_DIR = Path("./Results-PyPDEVS")
- OUTPUT_DIR.mkdir(exist_ok=True)
- # === LOAD & MERGE ===
- dfs = []
- for variant, path in FILES.items():
- df = pd.read_csv(path)
- df["variant"] = variant
- dfs.append(df)
- data = pd.concat(dfs, ignore_index=True)
- # === PROCESSING ===
- data["total_time"] = data["creation_time"] + data["setup_time"] + data["simulation_time"]
- agg = (
- data.groupby(["variant", "model_type", "depth", "width"], as_index=False)
- .agg({
- "creation_time": ["mean", "std"],
- "setup_time": ["mean", "std"],
- "simulation_time": ["mean", "std"],
- "total_time": ["mean", "std"]
- })
- )
- # Flatten multi-level columns
- agg.columns = ["_".join(col).rstrip("_") for col in agg.columns.values]
- sns.set_theme(style="whitegrid", font_scale=1.2)
- # === Scalability with Width ===
- for model in agg["model_type"].unique():
- subset = agg[agg["model_type"] == model]
- plt.figure(figsize=(7, 5))
- sns.lineplot(data=subset, x="width", y="simulation_time_mean", hue="variant", marker="o")
- plt.title(f"Scalability with Width – {model}")
- plt.xlabel("Width (# submodels per level)")
- plt.ylabel("Simulation time (s)")
- plt.tight_layout()
- plt.savefig(OUTPUT_DIR / f"scalability_width_{model}.png")
- plt.close()
- # === Scalability with Depth ===
- for model in agg["model_type"].unique():
- subset = agg[agg["model_type"] == model]
- plt.figure(figsize=(7, 5))
- sns.lineplot(data=subset, x="depth", y="simulation_time_mean", hue="variant", marker="o")
- plt.title(f"Scalability with Depth – {model}")
- plt.xlabel("Depth (levels)")
- plt.ylabel("Simulation time (s)")
- plt.tight_layout()
- plt.savefig(OUTPUT_DIR / f"scalability_depth_{model}.png")
- plt.close()
- # === Overhead Composition ===
- comp = data.melt(
- id_vars=["variant", "model_type", "depth", "width"],
- value_vars=["creation_time", "setup_time", "simulation_time"],
- var_name="phase",
- value_name="time"
- )
- plt.figure(figsize=(9, 6))
- sns.barplot(data=comp, x="variant", y="time", hue="phase", estimator="mean", errorbar="sd")
- plt.title("Average Overhead Composition by Variant")
- plt.ylabel("Mean time (s)")
- plt.tight_layout()
- plt.savefig(OUTPUT_DIR / "overhead_composition.png")
- plt.close()
- print(f"\nAnalysis complete. Plots and summary saved in: {OUTPUT_DIR}/")
|