"""Summarise bench.py rows: per (target, frame), the median of the 3 run p50s with the min-max of those run p50s (the A-vs-A spread, i.e. the noise floor), the median run p90, and the median server-side probe mean. python summarize.py rows-2026-09-27.json """ import json, statistics, sys from collections import defaultdict rows = json.load(open(sys.argv[1])) g = defaultdict(list) for r in rows: g[(r["target"], r["frame"])].append(r) targets = list(dict.fromkeys(r["target"] for r in rows)) frames = list(dict.fromkeys(r["frame"] for r in rows)) print(f"{'target':<14} {'frame':<17} {'p50 med':>8} {'p50 run min-max':>16} {'p90 med':>8} {'server med':>10} bad") for t in targets: for f in frames: rs = g[(t, f)] p50s = [r["p50"] for r in rs] srv = [r["server_probe_mean"] for r in rs if r["server_probe_mean"] is not None] print(f"{t:<14} {f:<17} {statistics.median(p50s):8.1f} {min(p50s):7.1f}-{max(p50s):<8.1f}" f" {statistics.median(r['p90'] for r in rs):8.1f}" f" {(statistics.median(srv) if srv else float('nan')):10.1f} {sum(r['bad'] for r in rs)}")