Generalize input bench macro
This commit is contained in:
parent
5d90f44f2b
commit
9a03a4f499
|
@ -39,5 +39,5 @@ mod tests {
|
|||
test!(part2() == 0);
|
||||
bench!(part1() == 0);
|
||||
bench!(part2() == 0);
|
||||
bench_input!(len == 0);
|
||||
bench_input!(Vec::len => 0);
|
||||
}' > src/bin/day$today.rs
|
||||
|
|
|
@ -44,5 +44,5 @@ mod tests {
|
|||
test!(part2() == 5);
|
||||
bench!(part1() == 1316);
|
||||
bench!(part2() == 1344);
|
||||
bench_input!(len == 2000);
|
||||
bench_input!(Vec::len => 2000);
|
||||
}
|
||||
|
|
|
@ -64,5 +64,5 @@ forward 2";
|
|||
test!(part2() == 900);
|
||||
bench!(part1() == 1698735);
|
||||
bench!(part2() == 1594785890);
|
||||
bench_input!(len == 1000);
|
||||
bench_input!(Vec::len => 1000);
|
||||
}
|
||||
|
|
|
@ -108,5 +108,5 @@ mod tests {
|
|||
test!(part2(5) == 230);
|
||||
bench!(part1(12) == 3549854);
|
||||
bench!(part2(12) == 3765399);
|
||||
bench_input!(len == 1000);
|
||||
bench_input!(Vec::len => 1000);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ macro_rules! bench {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! bench_input {
|
||||
($fn:ident == $expected_len:expr) => {
|
||||
($fn:expr => $expected:expr) => {
|
||||
#[bench]
|
||||
fn bench_input_parsing(b: &mut test::Bencher) {
|
||||
let raw = &read_file(DAY);
|
||||
b.iter(|| assert_eq!(parse_input(test::black_box(&raw)).$fn(), $expected_len));
|
||||
b.iter(|| assert_eq!($fn(&parse_input(test::black_box(&raw))), $expected));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user