aboutsummaryrefslogtreecommitdiff
path: root/src/tests/aoc_2022_14/benches
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/aoc_2022_14/benches')
-rw-r--r--src/tests/aoc_2022_14/benches/main.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tests/aoc_2022_14/benches/main.rs b/src/tests/aoc_2022_14/benches/main.rs
new file mode 100644
index 0000000..885b389
--- /dev/null
+++ b/src/tests/aoc_2022_14/benches/main.rs
@@ -0,0 +1,34 @@
+use aoc_2022_14::tests::*;
+use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
+use rand::{rngs::StdRng, SeedableRng};
+
+fn run_benches(c: &mut Criterion) {
+ c.bench_with_input(
+ 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_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_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_2022_14-part2", "large"),
+ &LARGE_INPUT,
+ |b, &inp| b.iter_batched_ref(|| parse_input(inp), |w| w.part2(), BatchSize::SmallInput),
+ );
+}
+
+criterion_group!(
+ name = benches;
+ config = Criterion::default().sample_size(10);
+ targets = run_benches
+);
+criterion_main!(benches);