From 7eca1339d724488003710d9401c5ba119e6ef0c3 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 7 Dec 2019 03:02:35 +0100 Subject: [PATCH] add benches for 2015 and 2018 --- Cargo.lock | 2 ++ aoc2015/Cargo.toml | 17 +++++++++++++++++ aoc2015/benches/bench.rs | 24 ++++++++++++++++++++++++ aoc2018/Cargo.toml | 17 +++++++++++++++++ aoc2018/benches/bench.rs | 22 ++++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 aoc2015/benches/bench.rs create mode 100644 aoc2018/benches/bench.rs diff --git a/Cargo.lock b/Cargo.lock index 44afe5a..4752ea0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,7 @@ name = "aoc2015" version = "0.1.0" dependencies = [ "aoc 0.1.0", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "md-5 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -17,6 +18,7 @@ name = "aoc2018" version = "0.1.0" dependencies = [ "aoc 0.1.0", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/aoc2015/Cargo.toml b/aoc2015/Cargo.toml index 279ebf8..2144355 100644 --- a/aoc2015/Cargo.toml +++ b/aoc2015/Cargo.toml @@ -6,7 +6,24 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dev-dependencies] + +criterion = "0.3" + [dependencies] aoc = { path = "../aoc" } md-5 = "0.8" + +[lib] +path = "src/lib.rs" +bench = false + +[[bin]] +name = "aoc2015" +path = "src/main.rs" +bench = false + +[[bench]] +name = "bench" +harness = false diff --git a/aoc2015/benches/bench.rs b/aoc2015/benches/bench.rs new file mode 100644 index 0000000..28f6a39 --- /dev/null +++ b/aoc2015/benches/bench.rs @@ -0,0 +1,24 @@ +use criterion::{criterion_group, criterion_main, Criterion}; + +use aoc2015::day01; +use aoc2015::day02; +use aoc2015::day03; +use aoc2015::day04; +use aoc2015::day05; +use aoc2015::day06; + +fn aoc2015_all(c: &mut Criterion) { + c.bench_function("day01", |b| b.iter(|| day01::run().unwrap())); + c.bench_function("day02", |b| b.iter(|| day02::run().unwrap())); + c.bench_function("day03", |b| b.iter(|| day03::run().unwrap())); + c.bench_function("day04", |b| b.iter(|| day04::run().unwrap())); + c.bench_function("day05", |b| b.iter(|| day05::run().unwrap())); + c.bench_function("day06", |b| b.iter(|| day06::run().unwrap())); +} + +criterion_group! { + name = all_days; + config = Criterion::default().sample_size(10); + targets = aoc2015_all +} +criterion_main!(all_days); diff --git a/aoc2018/Cargo.toml b/aoc2018/Cargo.toml index 5a89598..2ea04c2 100644 --- a/aoc2018/Cargo.toml +++ b/aoc2018/Cargo.toml @@ -5,7 +5,24 @@ authors = ["Antoine Martin "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +# +[dev-dependencies] + +criterion = "0.3" [dependencies] aoc = { path = "../aoc" } + +[lib] +path = "src/lib.rs" +bench = false + +[[bin]] +name = "aoc2018" +path = "src/main.rs" +bench = false + +[[bench]] +name = "bench" +harness = false diff --git a/aoc2018/benches/bench.rs b/aoc2018/benches/bench.rs new file mode 100644 index 0000000..3322203 --- /dev/null +++ b/aoc2018/benches/bench.rs @@ -0,0 +1,22 @@ +use criterion::{criterion_group, criterion_main, Criterion}; + +use aoc2018::day01; +use aoc2018::day02; +use aoc2018::day03; +use aoc2018::day04; +use aoc2018::day05; + +fn aoc2018_all(c: &mut Criterion) { + c.bench_function("day01", |b| b.iter(|| day01::run().unwrap())); + c.bench_function("day02", |b| b.iter(|| day02::run().unwrap())); + c.bench_function("day03", |b| b.iter(|| day03::run().unwrap())); + c.bench_function("day04", |b| b.iter(|| day04::run().unwrap())); + c.bench_function("day05", |b| b.iter(|| day05::run().unwrap())); +} + +criterion_group! { + name = all_days; + config = Criterion::default().sample_size(10); + targets = aoc2018_all +} +criterion_main!(all_days);