Add custom sieve and trials arguments to benchmark script.
This commit is contained in:
23
benchmark.sh
23
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user