Files
Karoy Lorentey 11a49663d0 [Benchmarks] Update benchmarking sub-package
- Fix issues with the main package no longer exposing internal helper functions
- Move Rust benchmarks behind an EnableRustBenchmarks trait
- Allow traits to be enabled in `Utils/run-benchmarks.sh` through the BENCHMARK_TRAITS environment variable.
2026-03-05 19:39:22 -08:00

48 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
set -eu
srcroot="$(dirname "$0")/../Benchmarks"
results="batch.results"
command="${1:-help}"
shift || :
if [ "$(uname)" = "Darwin" ]; then
swift="xcrun swift"
else
swift="swift"
fi
run() {
local flags
flags="-c release"
flags="$flags -Xswiftc -Xllvm -Xswiftc -align-module-to-page-size"
flags="$flags --traits ${BENCHMARK_TRAITS:-default}"
$swift run --package-path "$srcroot" $flags benchmark "$@"
}
case "$command" in
batch-run)
revision="$(git rev-parse HEAD)"
run library run "$results" \
--source-url "https://github.com/apple/swift-collections/tree/$revision" \
--mode replace-all \
--max-size 4M --cycles 3 \
--amortized-cutoff 10us \
"$@"
;;
batch-render)
run library render "$results" \
--min-time 100ps --max-time 10us \
--min-size 1 --max-size 4M \
"$@"
;;
batch-clean)
rm -rf "$out"/results
;;
*)
run "$command" "$@"
;;
esac