diff options
author | Aria Shrimpton <me@aria.rip> | 2024-02-29 16:10:26 +0000 |
---|---|---|
committer | Aria Shrimpton <me@aria.rip> | 2024-02-29 16:10:26 +0000 |
commit | 1b476265f3f6043529d252db5353c27ebd0507b3 (patch) | |
tree | e6b96d2b6d29f44a52e8aa3b7d78a7a891ea9f5f | |
parent | bb5ec77c534f77ae27856a36e8fa459a1b19356e (diff) |
rename benchmark stuff to be more consistent
-rw-r--r-- | src/tests/Cargo.toml | 8 | ||||
-rw-r--r-- | src/tests/aoc-2021-09/benches/main.rs | 31 | ||||
-rw-r--r-- | src/tests/aoc-2022-08/benches/main.rs | 31 | ||||
-rw-r--r-- | src/tests/aoc-2022-09/benches/main.rs | 31 | ||||
-rw-r--r-- | src/tests/aoc_2021_09/Cargo.toml (renamed from src/tests/aoc-2021-09/Cargo.toml) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2021_09/benches/main.rs | 39 | ||||
-rw-r--r-- | src/tests/aoc_2021_09/src/lib.rs (renamed from src/tests/aoc-2021-09/src/lib.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2021_09/src/types.pr.rs (renamed from src/tests/aoc-2021-09/src/types.pr.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_08/Cargo.toml (renamed from src/tests/aoc-2022-08/Cargo.toml) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_08/benches/main.rs | 39 | ||||
-rw-r--r-- | src/tests/aoc_2022_08/src/lib.rs (renamed from src/tests/aoc-2022-08/src/lib.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_08/src/types.pr.rs (renamed from src/tests/aoc-2022-08/src/types.pr.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_09/Cargo.toml (renamed from src/tests/aoc-2022-09/Cargo.toml) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_09/benches/main.rs | 39 | ||||
-rw-r--r-- | src/tests/aoc_2022_09/src/lib.rs (renamed from src/tests/aoc-2022-09/src/lib.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_09/src/types.pr.rs (renamed from src/tests/aoc-2022-09/src/types.pr.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_14/Cargo.toml (renamed from src/tests/aoc-2022-14/Cargo.toml) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_14/benches/main.rs (renamed from src/tests/aoc-2022-14/benches/main.rs) | 8 | ||||
-rw-r--r-- | src/tests/aoc_2022_14/src/lib.rs (renamed from src/tests/aoc-2022-14/src/lib.rs) | 0 | ||||
-rw-r--r-- | src/tests/aoc_2022_14/src/types.pr.rs (renamed from src/tests/aoc-2022-14/src/types.pr.rs) | 0 |
20 files changed, 125 insertions, 101 deletions
diff --git a/src/tests/Cargo.toml b/src/tests/Cargo.toml index de68bbe..85b4f1c 100644 --- a/src/tests/Cargo.toml +++ b/src/tests/Cargo.toml @@ -4,10 +4,10 @@ members = [ "example_sets", "example_stack", "example_mapping", - "aoc-2021-09", - "aoc-2022-08", - "aoc-2022-09", - "aoc-2022-14", + "aoc_2021_09", + "aoc_2022_08", + "aoc_2022_09", + "aoc_2022_14", "prime_sieve" ] diff --git a/src/tests/aoc-2021-09/benches/main.rs b/src/tests/aoc-2021-09/benches/main.rs deleted file mode 100644 index c5a2037..0000000 --- a/src/tests/aoc-2021-09/benches/main.rs +++ /dev/null @@ -1,31 +0,0 @@ -use aoc_2021_09::HeightMap; -use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; -use rand::{rngs::StdRng, SeedableRng}; - -fn run_benches(c: &mut Criterion) { - let mut rng = StdRng::seed_from_u64(42); - for size in [100].iter() { - c.bench_with_input(BenchmarkId::new("aoc-202109-part1", size), size, |b, &n| { - b.iter_batched_ref( - || HeightMap::gen(&mut rng, n), - |map| map.part1(), - BatchSize::SmallInput, - ) - }); - - c.bench_with_input(BenchmarkId::new("aoc-202109-part2", size), size, |b, &n| { - b.iter_batched_ref( - || HeightMap::gen(&mut rng, n), - |map| map.part2(), - BatchSize::SmallInput, - ) - }); - } -} - -criterion_group!( - name = benches; - config = Criterion::default().sample_size(10); - targets = run_benches -); -criterion_main!(benches); diff --git a/src/tests/aoc-2022-08/benches/main.rs b/src/tests/aoc-2022-08/benches/main.rs deleted file mode 100644 index 1949113..0000000 --- a/src/tests/aoc-2022-08/benches/main.rs +++ /dev/null @@ -1,31 +0,0 @@ -use aoc_2022_08::HeightMap; -use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; -use rand::{rngs::StdRng, SeedableRng}; - -fn run_benches(c: &mut Criterion) { - let mut rng = StdRng::seed_from_u64(42); - for size in [1000, 2000].iter() { - c.bench_with_input(BenchmarkId::new("aoc-202208-part1", size), size, |b, &n| { - b.iter_batched_ref( - || HeightMap::gen(&mut rng, n), - |map| map.part1(), - BatchSize::SmallInput, - ) - }); - - c.bench_with_input(BenchmarkId::new("aoc-202208-part2", size), size, |b, &n| { - b.iter_batched_ref( - || HeightMap::gen(&mut rng, n), - |map| map.part2(), - BatchSize::SmallInput, - ) - }); - } -} - -criterion_group!( - name = benches; - config = Criterion::default().sample_size(10); - targets = run_benches -); -criterion_main!(benches); diff --git a/src/tests/aoc-2022-09/benches/main.rs b/src/tests/aoc-2022-09/benches/main.rs deleted file mode 100644 index 6eb13e4..0000000 --- a/src/tests/aoc-2022-09/benches/main.rs +++ /dev/null @@ -1,31 +0,0 @@ -use aoc_2022_09::{gen_moves, part1, part2}; -use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; -use rand::{rngs::StdRng, SeedableRng}; - -fn run_benches(c: &mut Criterion) { - let mut rng = StdRng::seed_from_u64(42); - for size in [100, 1000, 2000].iter() { - c.bench_with_input(BenchmarkId::new("aoc-202209-part1", size), size, |b, &n| { - b.iter_batched_ref( - || gen_moves(&mut rng, n).collect::<Vec<_>>(), - |moves| part1(moves.iter()), - BatchSize::SmallInput, - ) - }); - - c.bench_with_input(BenchmarkId::new("aoc-202209-part2", size), size, |b, &n| { - b.iter_batched_ref( - || gen_moves(&mut rng, n).collect::<Vec<_>>(), - |moves| part2(moves.iter()), - BatchSize::SmallInput, - ) - }); - } -} - -criterion_group!( - name = benches; - config = Criterion::default().sample_size(10); - targets = run_benches -); -criterion_main!(benches); diff --git a/src/tests/aoc-2021-09/Cargo.toml b/src/tests/aoc_2021_09/Cargo.toml index 49da8bb..49da8bb 100644 --- a/src/tests/aoc-2021-09/Cargo.toml +++ b/src/tests/aoc_2021_09/Cargo.toml diff --git a/src/tests/aoc_2021_09/benches/main.rs b/src/tests/aoc_2021_09/benches/main.rs new file mode 100644 index 0000000..cc9b460 --- /dev/null +++ b/src/tests/aoc_2021_09/benches/main.rs @@ -0,0 +1,39 @@ +use aoc_2021_09::HeightMap; +use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; +use rand::{rngs::StdRng, SeedableRng}; + +fn run_benches(c: &mut Criterion) { + let mut rng = StdRng::seed_from_u64(42); + for size in [100].iter() { + c.bench_with_input( + BenchmarkId::new("aoc_2021_09-part1", size), + size, + |b, &n| { + b.iter_batched_ref( + || HeightMap::gen(&mut rng, n), + |map| map.part1(), + BatchSize::SmallInput, + ) + }, + ); + + c.bench_with_input( + BenchmarkId::new("aoc_2021_09-part2", size), + size, + |b, &n| { + b.iter_batched_ref( + || HeightMap::gen(&mut rng, n), + |map| map.part2(), + BatchSize::SmallInput, + ) + }, + ); + } +} + +criterion_group!( + name = benches; + config = Criterion::default().sample_size(10); + targets = run_benches +); +criterion_main!(benches); diff --git a/src/tests/aoc-2021-09/src/lib.rs b/src/tests/aoc_2021_09/src/lib.rs index 9ada752..9ada752 100644 --- a/src/tests/aoc-2021-09/src/lib.rs +++ b/src/tests/aoc_2021_09/src/lib.rs diff --git a/src/tests/aoc-2021-09/src/types.pr.rs b/src/tests/aoc_2021_09/src/types.pr.rs index 8441695..8441695 100644 --- a/src/tests/aoc-2021-09/src/types.pr.rs +++ b/src/tests/aoc_2021_09/src/types.pr.rs diff --git a/src/tests/aoc-2022-08/Cargo.toml b/src/tests/aoc_2022_08/Cargo.toml index 449bbdb..449bbdb 100644 --- a/src/tests/aoc-2022-08/Cargo.toml +++ b/src/tests/aoc_2022_08/Cargo.toml diff --git a/src/tests/aoc_2022_08/benches/main.rs b/src/tests/aoc_2022_08/benches/main.rs new file mode 100644 index 0000000..462480e --- /dev/null +++ b/src/tests/aoc_2022_08/benches/main.rs @@ -0,0 +1,39 @@ +use aoc_2022_08::HeightMap; +use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; +use rand::{rngs::StdRng, SeedableRng}; + +fn run_benches(c: &mut Criterion) { + let mut rng = StdRng::seed_from_u64(42); + for size in [1000, 2000].iter() { + c.bench_with_input( + BenchmarkId::new("aoc_2022_08-part1", size), + size, + |b, &n| { + b.iter_batched_ref( + || HeightMap::gen(&mut rng, n), + |map| map.part1(), + BatchSize::SmallInput, + ) + }, + ); + + c.bench_with_input( + BenchmarkId::new("aoc_2022_08-part2", size), + size, + |b, &n| { + b.iter_batched_ref( + || HeightMap::gen(&mut rng, n), + |map| map.part2(), + BatchSize::SmallInput, + ) + }, + ); + } +} + +criterion_group!( + name = benches; + config = Criterion::default().sample_size(10); + targets = run_benches +); +criterion_main!(benches); diff --git a/src/tests/aoc-2022-08/src/lib.rs b/src/tests/aoc_2022_08/src/lib.rs index 9f60ac8..9f60ac8 100644 --- a/src/tests/aoc-2022-08/src/lib.rs +++ b/src/tests/aoc_2022_08/src/lib.rs diff --git a/src/tests/aoc-2022-08/src/types.pr.rs b/src/tests/aoc_2022_08/src/types.pr.rs index 5e3950c..5e3950c 100644 --- a/src/tests/aoc-2022-08/src/types.pr.rs +++ b/src/tests/aoc_2022_08/src/types.pr.rs diff --git a/src/tests/aoc-2022-09/Cargo.toml b/src/tests/aoc_2022_09/Cargo.toml index f806c9c..f806c9c 100644 --- a/src/tests/aoc-2022-09/Cargo.toml +++ b/src/tests/aoc_2022_09/Cargo.toml diff --git a/src/tests/aoc_2022_09/benches/main.rs b/src/tests/aoc_2022_09/benches/main.rs new file mode 100644 index 0000000..dd96209 --- /dev/null +++ b/src/tests/aoc_2022_09/benches/main.rs @@ -0,0 +1,39 @@ +use aoc_2022_09::{gen_moves, part1, part2}; +use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; +use rand::{rngs::StdRng, SeedableRng}; + +fn run_benches(c: &mut Criterion) { + let mut rng = StdRng::seed_from_u64(42); + for size in [100, 1000, 2000].iter() { + c.bench_with_input( + BenchmarkId::new("aoc_2022_09-part1", size), + size, + |b, &n| { + b.iter_batched_ref( + || gen_moves(&mut rng, n).collect::<Vec<_>>(), + |moves| part1(moves.iter()), + BatchSize::SmallInput, + ) + }, + ); + + c.bench_with_input( + BenchmarkId::new("aoc_2022_09-part2", size), + size, + |b, &n| { + b.iter_batched_ref( + || gen_moves(&mut rng, n).collect::<Vec<_>>(), + |moves| part2(moves.iter()), + BatchSize::SmallInput, + ) + }, + ); + } +} + +criterion_group!( + name = benches; + config = Criterion::default().sample_size(10); + targets = run_benches +); +criterion_main!(benches); diff --git a/src/tests/aoc-2022-09/src/lib.rs b/src/tests/aoc_2022_09/src/lib.rs index 9bb7364..9bb7364 100644 --- a/src/tests/aoc-2022-09/src/lib.rs +++ b/src/tests/aoc_2022_09/src/lib.rs diff --git a/src/tests/aoc-2022-09/src/types.pr.rs b/src/tests/aoc_2022_09/src/types.pr.rs index d4225a9..d4225a9 100644 --- a/src/tests/aoc-2022-09/src/types.pr.rs +++ b/src/tests/aoc_2022_09/src/types.pr.rs diff --git a/src/tests/aoc-2022-14/Cargo.toml b/src/tests/aoc_2022_14/Cargo.toml index b8c00f5..b8c00f5 100644 --- a/src/tests/aoc-2022-14/Cargo.toml +++ b/src/tests/aoc_2022_14/Cargo.toml diff --git a/src/tests/aoc-2022-14/benches/main.rs b/src/tests/aoc_2022_14/benches/main.rs index 8ca2664..885b389 100644 --- a/src/tests/aoc-2022-14/benches/main.rs +++ b/src/tests/aoc_2022_14/benches/main.rs @@ -4,23 +4,23 @@ use rand::{rngs::StdRng, SeedableRng}; fn run_benches(c: &mut Criterion) { c.bench_with_input( - BenchmarkId::new("aoc-202214-part1", "small"), + BenchmarkId::new("aoc_2022_14-part1", "small"), &SMALL_INPUT, |b, &inp| b.iter_batched_ref(|| parse_input(inp), |w| w.part1(), BatchSize::SmallInput), ); c.bench_with_input( - BenchmarkId::new("aoc-202214-part1", "large"), + BenchmarkId::new("aoc_2022_14-part1", "large"), &LARGE_INPUT, |b, &inp| b.iter_batched_ref(|| parse_input(inp), |w| w.part1(), BatchSize::SmallInput), ); c.bench_with_input( - BenchmarkId::new("aoc-202214-part2", "small"), + BenchmarkId::new("aoc_2022_14-part2", "small"), &SMALL_INPUT, |b, &inp| b.iter_batched_ref(|| parse_input(inp), |w| w.part2(), BatchSize::SmallInput), ); c.bench_with_input( - BenchmarkId::new("aoc-202214-part2", "large"), + BenchmarkId::new("aoc_2022_14-part2", "large"), &LARGE_INPUT, |b, &inp| b.iter_batched_ref(|| parse_input(inp), |w| w.part2(), BatchSize::SmallInput), ); diff --git a/src/tests/aoc-2022-14/src/lib.rs b/src/tests/aoc_2022_14/src/lib.rs index 3494e2e..3494e2e 100644 --- a/src/tests/aoc-2022-14/src/lib.rs +++ b/src/tests/aoc_2022_14/src/lib.rs diff --git a/src/tests/aoc-2022-14/src/types.pr.rs b/src/tests/aoc_2022_14/src/types.pr.rs index 9d36060..9d36060 100644 --- a/src/tests/aoc-2022-14/src/types.pr.rs +++ b/src/tests/aoc_2022_14/src/types.pr.rs |