39 lines
1.2 KiB
Bash
Executable file
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 "$@"
|