Files
tso-paper-eval/analysis/values/cpu.py
T
2026-05-27 21:00:28 +02:00

29 lines
908 B
Python

"""Sender + receiver CPU per (experiment, solution): mean and sample SD in %."""
from pathlib import Path
import pandas as pd
METRICS = {
"sender-cpu": "cpu_sender",
"receiver-cpu": "cpu_receiver",
}
def compute(derived: Path) -> tuple[dict[str, str], list[Path]]:
out: dict[str, str] = {}
sources: list[Path] = []
for exp_dir in sorted(p for p in derived.iterdir() if p.is_dir()):
runs = exp_dir / "runs.csv"
if not runs.exists():
continue
sources.append(runs)
df = pd.read_csv(runs)
for sol, sub in df.groupby("solution", sort=True):
for metric, col in METRICS.items():
x = sub[col].to_numpy()
base = f"{exp_dir.name}/{metric}/{sol}"
out[f"{base}/mean-pct"] = f"{x.mean():.2f}"
out[f"{base}/sd-pct"] = f"{x.std(ddof=1):.2f}"
return out, sources