# P0 Reproducible Benchmark Harness and Initial Baseline Task ID: X-BASE-05 Phase: P0 Status: APPROVED ## 1. Context and baseline `PERFORMANCE.md` requires reproducible workload manifests, separate empty-harness baselines, median/p95/p99/95%-CI statistics over >= 5 warmup and >= 20 measured repetitions, and JSON raw sample artifacts before optimizing foundation code. ## 2. Deliverables - `VOID_ENABLE_BENCHMARKS` CMake option in `CMakeLists.txt`. - `benchmarks/CMakeLists.txt` and `benchmarks/FoundationBench.cpp` (`VoidFoundationBench`). - `tests/corpus/README.md` defining seeded parser/codec corpus layout. ## 3. Exact files and interfaces - `CMakeLists.txt`: add `option(VOID_ENABLE_BENCHMARKS ... OFF)` and `add_subdirectory(benchmarks)` when enabled. - `benchmarks/CMakeLists.txt`: build `VoidFoundationBench` linking available foundation targets (`Core`, `Functional`, `Containers`, `Math`, `Time`, `Binary`, `Data`). - `benchmarks/FoundationBench.cpp`: - Flags: `--warmup ` (5), `--reps ` (20), `--ops ` (10000), `--json `, `--filter `. - Empty harness baseline (`harness_empty_loop`) plus 12 foundation workloads (`core_uuid_*`, `core_hash_*`, `functional_*`, `math_checked_add_loop`, `containers_*`, `binary_reader_u64_be`, `data_json_*`). - Reports median, min, max, p95, p99 (nearest-rank), 95% CI half-width, ops/sec, raw samples, and environment metadata. - `tests/corpus/README.md`: corpus conventions for `Binary`, `Data`, `Text`. ## 4. Edge cases - Do not subtract harness baseline into negative latencies; report harness baseline separately. - Must compile cleanly under `-DVOID_WARNINGS_AS_ERRORS=ON` and work in selected foundation builds. ## 5. Acceptance criteria - `VoidFoundationBench --json /tmp/void-p0-bench/baseline.json` exits `0` and produces valid parseable JSON with all 13 records (harness + 12 workloads). - P0 records (`STATE.md`, `TASKS.md`, `VERIFICATION.md`) updated with exact observed command outputs. ## 6. Verification commands ```sh cmake -S . -B /tmp/void-p0-bench -G Ninja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DVOID_ENABLED_MODULES="Core;Functional;Containers;Math;Time;Binary;Data" \ -DVOID_ENABLE_TESTING=OFF -DVOID_ENABLE_BENCHMARKS=ON -DVOID_WARNINGS_AS_ERRORS=ON cmake --build /tmp/void-p0-bench --parallel 4 /tmp/void-p0-bench/benchmarks/VoidFoundationBench --json /tmp/void-p0-bench/baseline.json python3 -m json.tool /tmp/void-p0-bench/baseline.json >/dev/null ```