#!/usr/bin/env python3 """Multi-run perf measurement harness for fold (see docs/internal/perf-audit.md). Single-run wall-clock diffs at fold's curl-baseline scale carry ~15% run-to-run variance — too noisy to attribute sub-15% optimization wins. This script: 1. Runs `fold scan --profile ...` N times against a fixed target. 2. Captures the --profile JSON each run. 3. Reports median + IQR + min/max for total_wall_ms and the new per-detector phase timings (walker_ms, encode_ms, hook_ms, state_merge_ms). 4. Optionally diffs against a saved baseline JSON (recorded by an earlier invocation with --record). Convention: snapshots land under docs/internal/perf-audit/runs/