Something went wrong. Try again.
Backend environment for match hosting for lance.blue
Something went wrong. Try again.
Python
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#!/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): with Path(path).open() as fh: rows = list(csv.DictReader(fh)) 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( " (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")