Implement average of multiple trials.

This commit is contained in:
2025-12-05 16:15:44 +01:00
parent 073276da10
commit 98cb2f58ea

View File

@@ -1,6 +1,7 @@
#!/bin/bash
BIN="./target/release/indivisible"
TRIALS=20
if ! [ -f "$BIN" ]
then
@@ -8,4 +9,14 @@ then
exit 1
fi
time "$BIN" 100000000
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)
TOTAL=$(calc "$TOTAL + $TIME")
done
AVG=$(calc "$TOTAL / $TRIALS")
echo "Average time: ${AVG}s"