mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-04-30 20:12:31 +02:00
40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/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[@]}"
|