magicciv/tools/run-benches.sh
Natalie c96ab6c4fa fix(@projects/@magic-civilization): 🐛 update fauna species data consistency
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-05-03 20:02:25 -04:00

39 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Run all Rust microbenches in the simulator workspace.
#
# Usage:
# tools/run-benches.sh # all benches in all crates
# tools/run-benches.sh -p mc-ai # all benches in one crate
# tools/run-benches.sh -p mc-ai --bench tactical_state_build # specific bench
#
# All extra args are forwarded to `cargo bench`.
#
# Output: criterion writes to .local/build/rust/release/criterion/<bench>/. The
# console summary (median, p99 implicit via outlier report) is what the
# objectives consume — see `.project/objectives/p1-30.md` for the
# `tactical_state_build` reframed gate.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SIM_DIR="$REPO_ROOT/src/simulator"
if [[ ! -d "$SIM_DIR" ]]; then
echo "[run-benches] simulator dir not found at $SIM_DIR" >&2
exit 1
fi
cd "$SIM_DIR"
CARGO="${CARGO:-cargo}"
if ! command -v "$CARGO" >/dev/null 2>&1; then
if [[ -x "$HOME/.cargo/bin/cargo" ]]; then
CARGO="$HOME/.cargo/bin/cargo"
else
echo "[run-benches] cargo not found on PATH and ~/.cargo/bin/cargo absent" >&2
exit 1
fi
fi
echo "[run-benches] running cargo bench $* (cwd=$SIM_DIR)"
exec "$CARGO" bench "$@"