Something went wrong. Try again.
Initial spike on the project (via Claude)
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#!/usr/bin/env python3"""Summarize a bench CSV: what does game N+1 actually cost?
Reads the 'settled-game-N' checkpoints, which are taken after each newly startedgame has reached a real combat round, and reports the marginal delta."""import csvimport sysfrom pathlib import Path
def mb(kb): try: return int(kb) / 1024.0 except (TypeError, ValueError): return float("nan")
def main(path): rows = list(csv.DictReader(Path(path).open())) checkpoints = [r for r in rows if r["label"].startswith(("settled-game-", "unit-cache", "jvm-start", "final", "round-"))]
print(f"{'label':<22} {'games':>5} {'rounds':>7} {'rss MB':>9} {'liveHeap MB':>12} {'meta MB':>8}") print("-" * 68) prev_rss = prev_live = None for r in checkpoints: rss, live = mb(r["rssKb"]), mb(r["liveHeapKb"]) line = (f"{r['label']:<22} {r['gamesStarted']:>5} {r['totalRounds']:>7} " f"{rss:>9.0f} {live:>12.0f} {mb(r['metaspaceKb']):>8.0f}") if r["label"].startswith("settled-game-") and prev_rss is not None: line += f" (+{rss - prev_rss:.0f} rss, +{live - prev_live:.0f} live)" print(line) if r["label"].startswith(("settled-game-", "unit-cache")): prev_rss, prev_live = rss, live
settled = [r for r in rows if r["label"].startswith("settled-game-")] if len(settled) >= 2: first, last = settled[0], settled[-1] n = int(last["gamesStarted"]) - int(first["gamesStarted"]) if n > 0: d_rss = (mb(last["rssKb"]) - mb(first["rssKb"])) / n d_live = (mb(last["liveHeapKb"]) - mb(first["liveHeapKb"])) / n print() print(f"marginal cost per additional game, games {first['gamesStarted']}..{last['gamesStarted']}:") print(f" RSS ~{d_rss:.0f} MB/game") print(f" live heap ~{d_live:.0f} MB/game") print(f" (one-time shared unit cache is paid once, see unit-cache-loaded row)")
if __name__ == "__main__": main(sys.argv[1] if len(sys.argv) > 1 else "results/bench.csv")