diff options
author | Aria Shrimpton <me@aria.rip> | 2024-01-23 12:57:13 +0000 |
---|---|---|
committer | Aria Shrimpton <me@aria.rip> | 2024-01-23 12:57:13 +0000 |
commit | 55a2fa3276d400ba2b3c865719b541ad8a6b3943 (patch) | |
tree | 29229a57cecc1670381c7691deff8c2c530eb2e0 /src/tests | |
parent | 0a9b6cfa4aa85d9f4512c6a12564a4c1a87ba313 (diff) |
fixes for prime_sieve
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/prime_sieve/benches/main.rs | 11 | ||||
-rw-r--r-- | src/tests/prime_sieve/src/lib.rs | 2 | ||||
-rw-r--r-- | src/tests/prime_sieve/src/types.pr.rs | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/tests/prime_sieve/benches/main.rs b/src/tests/prime_sieve/benches/main.rs index fd04578..a055c26 100644 --- a/src/tests/prime_sieve/benches/main.rs +++ b/src/tests/prime_sieve/benches/main.rs @@ -3,10 +3,13 @@ use criterion::Criterion; use criterion::{criterion_group, criterion_main}; fn bench_sieve(c: &mut Criterion) { - let size: usize = 10; - c.bench_with_input(BenchmarkId::new("prime_sieve", size), &size, |b, &n| { - b.iter(|| prime_sieve::prime_sieve(n)); - }); + let mut group = c.benchmark_group("prime_sieve"); + group.sample_size(20); + for size in [10_000, 20_000, 50_000].iter() { + group.bench_with_input(BenchmarkId::new("prime_sieve", size), size, |b, &n| { + b.iter(|| prime_sieve::prime_sieve(n)); + }); + } } criterion_group!(benches, bench_sieve); diff --git a/src/tests/prime_sieve/src/lib.rs b/src/tests/prime_sieve/src/lib.rs index 8d53e30..788e804 100644 --- a/src/tests/prime_sieve/src/lib.rs +++ b/src/tests/prime_sieve/src/lib.rs @@ -3,6 +3,8 @@ mod types; use types::*; +use primrose_library::traits::{Container, Stack}; + /// Find all primes < `n` using the sieve of eratosthenes pub fn prime_sieve(n: usize) -> Primes<usize> { // Add numbers to sieve through diff --git a/src/tests/prime_sieve/src/types.pr.rs b/src/tests/prime_sieve/src/types.pr.rs index 2006302..a7f04bf 100644 --- a/src/tests/prime_sieve/src/types.pr.rs +++ b/src/tests/prime_sieve/src/types.pr.rs @@ -9,5 +9,5 @@ property ascending<T> { type Sieve<S> = {c impl (Container, Stack) | (lifo c)} -type Primes<S> = {c impl (Container, Stack) | (ascending c)} +type Primes<S> = {c impl (Container) | (ascending c)} *ENDSPEC*/ |