Compare commits

...

4 Commits

2 changed files with 24 additions and 2 deletions

22
benchmark.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
BIN="./target/release/indivisible"
TRIALS=20
if ! [ -f "$BIN" ]
then
>&2 echo "Release build not available. Please run 'cargo build -r'."
exit 1
fi
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"

View File

@@ -31,7 +31,7 @@ struct Opt {
import:Option<PathBuf>,
#[structopt(short, long, help = "Test if num is prime instead of generation")]
test:bool,
#[structopt(help = "Ordinal 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:u64,
#[structopt(short, long, name = "n", default_value = "1", help = "Number of threads to spawn")]
jobs:u64,
@@ -92,7 +92,7 @@ fn main() {
}
for i in 5..=(f64::sqrt(opts.num as f64) as u64 + 1) as usize {
if !arr[i as usize] {
if !arr[i] {
continue;
}