Day 1 benchmarks

This commit is contained in:
Smaug123
2021-05-15 10:39:26 +01:00
parent 0dcca4db86
commit 12b1ed73d8
3 changed files with 28 additions and 0 deletions

3
Cargo.lock generated
View File

@@ -179,6 +179,9 @@ dependencies = [
[[package]]
name = "day_1"
version = "0.1.0"
dependencies = [
"criterion",
]
[[package]]
name = "day_10"

View File

@@ -7,3 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "day_1"
harness = false

19
day_1/benches/day_1.rs Normal file
View File

@@ -0,0 +1,19 @@
use criterion::{criterion_group, criterion_main, Criterion};
use day_1::day_1::{input, part_1, part_2};
fn criterion_benchmark(c: &mut Criterion) {
let input = input();
c.bench_function("day 1 part 1", |b| {
b.iter(|| {
part_1(&input);
})
});
c.bench_function("day 1 part 2", |b| {
b.iter(|| {
part_2(&input);
})
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);