From 55a2fa3276d400ba2b3c865719b541ad8a6b3943 Mon Sep 17 00:00:00 2001 From: Aria Shrimpton Date: Tue, 23 Jan 2024 12:57:13 +0000 Subject: fixes for prime_sieve --- src/tests/prime_sieve/benches/main.rs | 11 +++++++---- src/tests/prime_sieve/src/lib.rs | 2 ++ src/tests/prime_sieve/src/types.pr.rs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/tests') 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 { // 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 { type Sieve = {c impl (Container, Stack) | (lifo c)} -type Primes = {c impl (Container, Stack) | (ascending c)} +type Primes = {c impl (Container) | (ascending c)} *ENDSPEC*/ -- cgit v1.2.3