bench: split to separate package

Unfortunately cargo doesn't allow optional dev dependencies (see
rust-lang/cargo#1596) so this is the workaround.

Previously, running `cargo test` triggered the build of all dev
dependencies, including criterion, which in turn pulls in a lot of
stuff. Running tests should be faster, hence this change.
This commit is contained in:
Antoine Martin 2020-12-15 12:06:24 +01:00
parent 99f599e910
commit 8d11c817f3
14 changed files with 98 additions and 47 deletions

View file

@ -0,0 +1,17 @@
[package]
name = "aoc2018_bench"
version = "0.1.0"
authors = ["Antoine Martin <antoine97.martin@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
aoc2018 = { path = "../" }
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "aoc2018_bench"
harness = false

View file

@ -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(30);
targets = aoc2018_all
}
criterion_main!(all_days);