34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Initial ssthresh per (solution, qlen) from slowstart raw text files."""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import numpy as np
|
|
|
|
|
|
def _read(path: Path) -> dict[int, np.ndarray]:
|
|
out = {}
|
|
for line in path.read_text().splitlines():
|
|
line = line.strip()
|
|
if not line:
|
|
continue
|
|
qlen, vals = line.split(":", 1)
|
|
out[int(qlen)] = np.array([float(v) for v in vals.split()])
|
|
return out
|
|
|
|
|
|
def compute(derived: Path) -> tuple[dict[str, str], list[Path]]:
|
|
raw_root = Path(os.environ.get("RAW_DATA_ROOT", derived.parent / "raw_data"))
|
|
raw = raw_root / "slowstart"
|
|
files = {"tso": raw / "tso.txt", "tso-pacing": raw / "tso_pacing.txt"}
|
|
if not all(p.exists() for p in files.values()):
|
|
return {}, []
|
|
|
|
out: dict[str, str] = {}
|
|
for sol, path in files.items():
|
|
for qlen, vals in _read(path).items():
|
|
base = f"slowstart/{sol}/qlen-{qlen}"
|
|
out[f"{base}/mean-pkts"] = f"{vals.mean():.0f}"
|
|
out[f"{base}/sd-pkts"] = f"{vals.std(ddof=1):.0f}"
|
|
out[f"{base}/n-runs"] = str(vals.size)
|
|
return out, list(files.values())
|