From fac6119d43f284443d1af024cdacb11d22238d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 5 Nov 2024 23:06:10 +0100 Subject: [PATCH] chore: Allow setting rounds in benchmark --- tests/compare_benchmarks.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/compare_benchmarks.sh b/tests/compare_benchmarks.sh index d05a52dbde..b501e77d06 100755 --- a/tests/compare_benchmarks.sh +++ b/tests/compare_benchmarks.sh @@ -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}" @@ -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}"