#!/bin/bash set -euo pipefail cd "$(dirname "$0")/.." mode=${1:?Choose compare or record.} output=${2:-build/bench-results.json} baseline=${3:-} calibrate=${4:-0} case "$mode" in compare|record) ;; *) printf 'Choose compare or record.\n' >&2; exit 2 ;; esac if [[ $calibrate != 0 ]]; then printf 'Calibration scaling is no longer supported; retired instructions are the gate.\n' >&2 exit 2 fi identity=$(Scripts/parcel-dev.sh bench-identity) baseline=${baseline:-Benchmarks/baselines/$identity} if [[ $mode == compare && ! -f $baseline ]]; then printf 'no baseline for this machine, run make bench-record on a quiet machine\nExpected: %s\n' "$baseline" >&2 exit 1 fi quiet=build/bench-quiet.json status=0 Scripts/quiet-check.sh --output "$quiet" || status=$? if [[ $status != 0 ]]; then if [[ $status != 3 || $mode == record || ${BENCH_STRICT_QUIET:-0} == 1 ]]; then exit "$status"; fi printf 'Host is not quiet: instruction gate only; CPU/time budgets are diagnostic.\n' fi record=0 if [[ $mode == record ]]; then record=1 printf 'Recording %s. Review the host conditions and results before committing.\n' "$baseline" fi Scripts/swift-build.sh --prepare SWIFT_DETERMINISTIC_HASHING=1 PARCEL_BENCH=1 PARCEL_BENCH_RECORD="$record" PARCEL_BENCH_OUTPUT="$output" \ PARCEL_BENCH_BASELINE="$baseline" PARCEL_BENCH_QUIET="$quiet" \ swift test -c release --no-parallel --filter '^ParcelPerformanceTests\.'