lean4-htt/tests/bench-radar/build/run
Garmelon a0d0abcdc5
chore: update and add benchmark metrics (#11420)
This PR adds per-module `.ilean` and `.olean` file size metrics, global
and per-module cycle counting, and adds back `lean --stat`-based
metrics. It also renames some `size/*` metrics to get rid of the name
`stdlib`.
2025-11-28 14:40:43 +00:00

40 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euxo pipefail
BENCH="tests/bench-radar"
STAGE2="build/release/stage2"
STAGE3="build/release/stage3"
# Build previous stages and warm up stage3
cmake --preset release
timeout -s KILL 1h time make -C build/release -j"$(nproc)" stage3
find "$STAGE3" -name "*.olean" -delete
# Use stage2 binaries from now on
#
# Otherwise, tools like lakeprof use the global lean installation,
# which may not exist or be the right version.
export PATH="$PWD/$STAGE2/bin:$PATH"
# Substitute our own wrapper script
mv "$STAGE2/bin/lean" "$STAGE2/bin/lean.wrapped"
cp "$BENCH/build/lean_wrapper.py" "$STAGE2/bin/lean"
# Build stage3
"$BENCH/measure.py" -t build \
-m cycles -m instructions -m maxrss -m task-clock -m wall-clock -- \
lakeprof record -- \
make -C build/release -j"$(nproc)" stage3
# Analyze lakeprof data
mv lakeprof.log src
pushd src
lakeprof report -pj | jq -r '"radar::measurement=\({metric: "build/lakeprof/longest build path//wall-clock", value: .[-1][2], unit: "s"})"'
lakeprof report -rj | jq -r '"radar::measurement=\({metric: "build/lakeprof/longest rebuild path//wall-clock", value: .[-1][2], unit: "s"})"'
popd
# Upload lakeprof report
# Guarded to prevent accidental uploads (which wouldn't work anyways) during local runs.
if [ -f build_upload_lakeprof_report ]; then
python3 "$BENCH/build/lakeprof_report_upload.py"
fi