Add custom sieve and trials arguments to benchmark script.

This commit is contained in:
2025-12-10 14:45:47 +01:00
parent be3fd52cfa
commit 5dde94ae8c

View File

@@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
BIN="./target/release/indivisible" EXE="./target/release/indivisible"
OPTIONS=()
TRIALS=20 TRIALS=20
if ! [ -f "$BIN" ] if ! [ -f "$EXE" ]
then then
>&2 echo "Release build not available. Please run 'cargo build -r'." >&2 echo "Release build not available. Please run 'cargo build -r'."
exit 1 exit 1
@@ -15,11 +16,27 @@ then
exit 1 exit 1
fi 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" echo "Calculating primes up to 100,000,000"
TOTAL="0" TOTAL="0"
for _ in $(seq "$TRIALS") for _ in $(seq "$TRIALS")
do 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") TOTAL=$(calc "$TOTAL + $TIME")
done done