Compare commits
3 Commits
be3fd52cfa
...
966574dd1f
| Author | SHA1 | Date | |
|---|---|---|---|
| 966574dd1f | |||
| 41bc18a17c | |||
| 5dde94ae8c |
25
benchmark.sh
25
benchmark.sh
@@ -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
|
||||||
|
|
||||||
echo "Calculating primes up to 100,000,000"
|
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 1,000,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[@]}" 1000000000 2>&1 >/dev/null)
|
||||||
TOTAL=$(calc "$TOTAL + $TIME")
|
TOTAL=$(calc "$TOTAL + $TIME")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ struct Opt {
|
|||||||
test:bool,
|
test:bool,
|
||||||
#[structopt(help = "Max of the prime to generate or number to test for primality")]
|
#[structopt(help = "Max of the prime to generate or number to test for primality")]
|
||||||
num:usize,
|
num:usize,
|
||||||
#[structopt(short, long, name = "SIZE", default_value = "1000", help = "Set a custom sieve size")]
|
#[structopt(short, long, name = "SIZE", default_value = "10485760", help = "Set a custom sieve size")]
|
||||||
sieve:usize,
|
sieve:usize,
|
||||||
//#[structopt(short, long, name = "n", default_value = "1", help = "Number of threads to spawn")]
|
//#[structopt(short, long, name = "n", default_value = "1", help = "Number of threads to spawn")]
|
||||||
//jobs:u64,
|
//jobs:u64,
|
||||||
|
|||||||
Reference in New Issue
Block a user