| 315 | |
| 316 | |
| 317 | def summarize(rows): |
| 318 | groups = {} |
| 319 | for row in rows: |
| 320 | groups.setdefault((row["mode"], row["scenario"]), []).append(row) |
| 321 | output = {} |
| 322 | for (mode, scenario), cases in groups.items(): |
| 323 | turns = [t for case in cases for t in case["turns"]] |
| 324 | checkpoints = [t["checkpoint_ms"] for t in turns if t["checkpoint_ok"]] |
| 325 | rate = [sum(t["events"] for t in c["turns"]) / (sum(t["append_wall_ms"] for t in c["turns"]) / 1000) for c in cases] |
| 326 | output[f"{mode}:{scenario}"] = { |
| 327 | "runs": len(cases), "turns": len(turns), "successful_checkpoints": len(checkpoints), |
| 328 | "median_events_s": statistics.median(rate), "min_events_s": min(rate), "max_events_s": max(rate), |
| 329 | "median_request_p50_ms": statistics.median(t["append_latency"]["p50_ms"] for t in turns), |
| 330 | "median_request_p95_ms": statistics.median(t["append_latency"]["p95_ms"] for t in turns), |
| 331 | "checkpoint": summary(checkpoints) if checkpoints else None} |
| 332 | return output |
| 333 | |
| 334 | |
| 335 | def main(): |