Skip to content

Commit

Permalink
chore: Allow setting rounds in benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Nov 5, 2024
1 parent 0738de0 commit fac6119
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/compare_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ set -o pipefail
# error on unset variables
set -u

[[ "$#" -eq 1 ]] || echo "One argument required, $# provided."
[[ "$#" -le 2 ]] || echo "At least one argument required, $# provided."

REF_CURRENT="$(git rev-parse --abbrev-ref HEAD)"
REF_TO_COMPARE=$1

COUNT=${2:-"1"}

echo "Running benchmarks ${COUNT} time(s)"

RESULT_CURRENT="$(mktemp)-${REF_CURRENT}"
RESULT_TO_COMPARE="$(mktemp)-${REF_TO_COMPARE}"

echo ""
echo "### Testing ${REF_CURRENT}"

go test -benchmem -run=NONE -bench=. ./... | tee "${RESULT_CURRENT}"
go test -benchmem -run=NONE -bench=. -count="${COUNT}" ./... | tee "${RESULT_CURRENT}"

echo ""
echo "### Done testing ${REF_CURRENT}"
Expand All @@ -27,7 +31,7 @@ echo "### Testing ${REF_TO_COMPARE}"

git checkout "${REF_TO_COMPARE}"

go test -benchmem -run=NONE -bench=. ./... | tee "${RESULT_TO_COMPARE}"
go test -benchmem -run=NONE -bench=. -count="${COUNT}" ./... | tee "${RESULT_TO_COMPARE}"

echo ""
echo "### Done testing ${REF_TO_COMPARE}"
Expand Down

0 comments on commit fac6119

Please sign in to comment.