#!/usr/bin/env bash
set -euo pipefail
show_help() {
cat <<'HELP'
Usage: bin/compare
Compare the declared pairs of saved benchmark reports under reports/raw/.
Requires the built harness/harness binary. Does not run new benchmarks.
OVERWRITES comparison reports under reports/comparisons/.
Exits nonzero if any declared comparison fails.
Example:
bin/build
bin/compare
For an individual comparison, use harness/harness compare --help.
Options:
-h, --help Show this help without performing work.
HELP
}
case "${1:-}" in
-h|--help|help) show_help; exit 0 ;;
"") ;;
*) printf 'Unexpected argument; use bin/compare --help\n' >&2; exit 2 ;;
esac
project_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$project_root"
mkdir -p reports/comparisons
failed=0
for concurrency in 1 8 32; do
harness/harness compare --baseline "reports/raw/django-v2-small-c$concurrency.json" \
--candidate "reports/raw/go-v2-small-c$concurrency.json" \
--output "reports/comparisons/v2-small-c$concurrency.json" || failed=1
harness/harness compare --baseline "reports/raw/django-v2-small-c$concurrency.json" \
--candidate "reports/raw/go-production-v2-small-c$concurrency.json" \
--output "reports/comparisons/production-v2-small-c$concurrency.json" || failed=1
done
for workload in posts search tag; do
harness/harness compare --baseline reports/raw/django-full-c1.json \
--candidate reports/raw/go-full-c1.json --workload "$workload" \
--output "reports/comparisons/full-$workload-c1.json" || failed=1
done
for workload in detail create comment; do
harness/harness compare --baseline "reports/raw/django-full-$workload-c1.json" \
--candidate "reports/raw/go-full-$workload-c1.json" \
--output "reports/comparisons/full-$workload-c1.json" || failed=1
done
for workload in user email; do
harness/harness compare --baseline "reports/raw/django-v2-full-$workload-c1.json" \
--candidate "reports/raw/go-v2-full-$workload-c1.json" \
--output "reports/comparisons/v2-full-$workload-c1.json" || failed=1
done
for workload in posts search tag; do
harness/harness compare --baseline "reports/raw/optimized-v2-full-$workload-c1.json" \
--candidate "reports/raw/go-bonus-v2-full-$workload-c1.json" \
--output "reports/comparisons/bonus-v2-full-$workload-c1.json" || failed=1
done
exit "$failed"