| 1 | #!/usr/bin/env python3 |
| 2 | """Aggregate probe runs: one row per (server directory without its |
| 3 | repetition suffix, run), median over repetitions with [min-max], from |
| 4 | <root>/<name>-<rep>/summary.jsonl. Written for the prototype matrix |
| 5 | (proto/live-push), used again for slice 1a's measurements. |
| 6 | |
| 7 | proto-table.py <root> |
| 8 | """ |
| 9 | import json, statistics, sys |
| 10 | from collections import defaultdict |
| 11 | from pathlib import Path |
| 12 | |
| 13 | root = Path(sys.argv[1]) |
| 14 | rows = defaultdict(list) |
| 15 | for path in sorted(root.glob("*/summary.jsonl")): |
| 16 | kind = path.parent.name.rsplit("-", 1)[0] if path.parent.name[-1].isdigit() else path.parent.name |
| 17 | for line in path.open(): |
| 18 | r = json.loads(line) |
| 19 | rows[(kind, r["label"])].append(r) |
| 20 | |
| 21 | def agg(xs, fmt="{:.0f}"): |
| 22 | xs = [x for x in xs if x == x] |
| 23 | if not xs: |
| 24 | return "-" |
| 25 | m = statistics.median(xs) |
| 26 | return fmt.format(m) + (f" [{fmt.format(min(xs))}–{fmt.format(max(xs))}]" if len(xs) > 1 else "") |
| 27 | |
| 28 | print("| Server | Run | n | Key → arrived p50 | p95 | Uploads/s per typist | Watcher GETs | Server CPU ms/s | CPU ms per upload | Alloc MB/s |") |
| 29 | print("|---|---|---|---|---|---|---|---|---|---|") |
| 30 | for (kind, label), rs in sorted(rows.items()): |
| 31 | secs = [r["seconds"] + 2 for r in rs] |
| 32 | uploads = [r["posts_per_s_per_typist"] * r["typists"] * s for r, s in zip(rs, secs)] |
| 33 | print(f"| {kind} | {label} | {len(rs)} | {agg([r['key_to_fetched'][0] for r in rs])} | {agg([r['key_to_fetched'][1] for r in rs])} | " |
| 34 | f"{agg([r['posts_per_s_per_typist'] for r in rs], '{:.1f}')} | {agg([r.get('watcher_gets_total', 0) for r in rs])} | " |
| 35 | f"{agg([r['server_cpu_ms_per_s'] for r in rs])} | {agg([r['server_cpu_ms'] / u for r, u in zip(rs, uploads)], '{:.1f}')} | " |
| 36 | f"{agg([r['server_alloc_mb'] / s for r, s in zip(rs, secs)])} |") |
| 37 | |