"""Citable-grade summary of run_v9_cite.sh output. cite_v9.py OUT_A [OUT_B] Per point (corpus, size, op): the per-round ratio v9/v9n of the medians of the reps in that round (both builds back to back, so drift cancels), over clean rounds only. Reports the median ratio, a bootstrap 95% CI of the median (percentile, 20000 resamples, fixed seed), the number of clean rounds, and whether every round was faster. With OUT_B, a second independent run: a point is CITABLE when B's median falls inside A's CI (our lab's cita rule), UNSTABLE otherwise. Pure stdlib. """ import random import statistics as st import sys from collections import defaultdict def ratios(path): data = defaultdict(list) for line in open(path): if not line.startswith("build="): continue f = dict(kv.split("=", 1) for kv in line.split() if "=" in kv) if f["clean"] != "1": continue data[(f["corpus"], int(f["size"]), f["op"], int(f["round"]), f["build"])].append(float(f["ms"])) out = defaultdict(list) for (c, s, op, r, b) in list(data): if b == "v9" and (c, s, op, r, "v9n") in data: out[(c, s, op)].append(st.median(data[(c, s, op, r, "v9")]) / st.median(data[(c, s, op, r, "v9n")])) return out def ci(xs, n=20000): rnd = random.Random(42) meds = sorted(st.median(rnd.choices(xs, k=len(xs))) for _ in range(n)) return meds[int(0.025 * n)], meds[int(0.975 * n) - 1] a = ratios(sys.argv[1]) b = ratios(sys.argv[2]) if len(sys.argv) > 2 else None print("v9 / v9n: median of per-round ratios [bootstrap 95% CI], clean rounds" + (", then run B" if b else "")) for k in sorted(a): xs = a[k]; lo, hi = ci(xs); m = st.median(xs) flag = " all-faster" if max(xs) < 1 else " all-slower" if min(xs) > 1 else "" line = f" {k[0]} {k[1]} {k[2]}: {m:.3f} [{lo:.3f}, {hi:.3f}] n={len(xs)}{flag}" if b and k in b: mb = st.median(b[k]); lob, hib = ci(b[k]) flagb = " all-faster" if max(b[k]) < 1 else "" line += f" | B {mb:.3f} [{lob:.3f}, {hib:.3f}] n={len(b[k])}{flagb} -> {'CITABLE' if lo <= mb <= hi else 'UNSTABLE'}" print(line)