ci: add benchmark workflow

This commit is contained in:
2026-04-17 10:07:22 +02:00
parent 846b6e6968
commit d10252cfaf
9 changed files with 762 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
mkdir -p benchmark-results
benchmark_json="${BENCHMARK_JSON:-benchmark-results/current.json}"
benchmark_dir="${BENCHMARK_HYPERFINE_DIR:-tests/benchmarks/hyperfine}"
shopt -s nullglob
benchmark_scripts=("$benchmark_dir"/benchmark_*.sh)
shopt -u nullglob
if [ "${#benchmark_scripts[@]}" -eq 0 ]; then
echo "No hyperfine benchmark scripts matching benchmark_*.sh found in $benchmark_dir" >&2
exit 1
fi
echo "Benchmark Python: $(command -v python)"
python -c 'import sys; print(sys.version)'
commands=()
names=()
for benchmark_script in "${benchmark_scripts[@]}"; do
title="$(sed -n 's/^# BENCHMARK_TITLE:[[:space:]]*//p' "$benchmark_script" | head -n 1)"
if [ -z "$title" ]; then
title="$(basename "$benchmark_script" .sh)"
fi
echo "Preflight benchmark script: $benchmark_script"
bash "$benchmark_script"
names+=(--command-name "$title")
commands+=("bash $(printf "%q" "$benchmark_script")")
done
hyperfine \
--show-output \
--warmup 1 \
--runs 5 \
"${names[@]}" \
--export-json "$benchmark_json" \
"${commands[@]}"