#!/usr/bin/env python3 """Print median whole-trace and per-repetition p99 poll times from bench JSON Lines.""" import argparse import json from collections import defaultdict from statistics import median parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("files", nargs="+") args = parser.parse_args() groups = defaultdict(list) for path in args.files: with open(path, encoding="utf-8") as stream: for line in stream: row = json.loads(line) if row["kind"] == "trial": groups[(row["slots"], row["scenario"], row["engine"], row["ordered"])].append(row) print("| Slots | Scenario | Engine | Ordered | Reps | Batch ms | Poll p99 ns |") print("|---:|---|---|---|---:|---:|---:|") for (slots, scenario, engine, ordered), rows in sorted(groups.items()): batch = median(row["batch_ns"] for row in rows) / 1_000_000 q99 = [row["poll_p99_ns"] for row in rows if "poll_p99_ns" in row] print(f"| {slots} | {scenario} | {engine} | {'yes' if ordered else 'no'} | {len(rows)} " f"| {batch:.3f} | {median(q99) if q99 else '—'} |")