From 5dde94ae8c9762e8e116b47987136ac89afb7225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Wed, 10 Dec 2025 14:45:47 +0100 Subject: [PATCH] Add custom sieve and trials arguments to benchmark script. --- benchmark.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/benchmark.sh b/benchmark.sh index 65d2f02..1a43549 100755 --- a/benchmark.sh +++ b/benchmark.sh @@ -1,9 +1,10 @@ #!/bin/bash -BIN="./target/release/indivisible" +EXE="./target/release/indivisible" +OPTIONS=() TRIALS=20 -if ! [ -f "$BIN" ] +if ! [ -f "$EXE" ] then >&2 echo "Release build not available. Please run 'cargo build -r'." exit 1 @@ -15,11 +16,27 @@ then exit 1 fi +while getopts "t:s:" opt +do + case "$opt" in + s) + OPTIONS=("${OPTIONS[@]}" -s "$OPTARG") + ;; + t) + TRIALS="$OPTARG" + ;; + *) + >&2 echo "Uknown option $opt" + exit 1 + ;; + esac +done + echo "Calculating primes up to 100,000,000" TOTAL="0" for _ in $(seq "$TRIALS") do - TIME=$(command time -f "%e" "$BIN" 100000000 2>&1 >/dev/null) + TIME=$(command time -f "%e" "$EXE" "${OPTIONS[@]}" 100000000 2>&1 >/dev/null) TOTAL=$(calc "$TOTAL + $TIME") done