Compare commits
4 Commits
c0f3f730ae
...
98cb2f58ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 98cb2f58ea | |||
| 073276da10 | |||
| 56a094730c | |||
| 3a4a5c8849 |
22
benchmark.sh
Executable file
22
benchmark.sh
Executable 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"
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user