#!/bin/bash # # bench.sh — Metrika # # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai # Copyright © 2026 Simon-Pierre Boucher. All rights reserved. # # Performance benchmark harness (CLAUDE.md §8). Generates a synthetic # dataset and times the core pipeline through metrika-cli. CI compares # against the budget table; regressions >10% fail the build. # # Usage: Tests/Bench/bench.sh [rows] (default 1,000,000) # set -euo pipefail export LC_ALL=C ROWS="${1:-1000000}" ROOT="$(cd "$(dirname "$0")/../.." && pwd)" DATA="$(mktemp -d)/bench.csv" trap 'rm -rf "$(dirname "$DATA")"' EXIT echo "generating $ROWS rows…" awk -v n="$ROWS" 'BEGIN { srand(42) print "revenue,price,region,firm_id" for (i = 1; i <= n; i++) { price = 5 + 15 * rand() region = (i % 3) + 1 revenue = exp(4 - 0.08 * price + 0.1 * region + 0.15 * (rand() - 0.5)) printf "%.6f,%.4f,%d,%d\n", revenue, price, region, (i % 500) + 1 } }' > "$DATA" cd "$ROOT/MetrikaKit" swift build -c release --product metrika-cli >/dev/null CLI=".build/release/metrika-cli" bench() { # bench