Skip to content

Commit 2968c34

Browse files
committed
Fix criterion.rs runner
1 parent e025f14 commit 2968c34

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# generated by Gradle Wrapper
22
kt/gradlew linguist-generated
33
kt/gradlew.bat linguist-generated
4+
5+
# generated by Poetry
6+
py/poetry.lock linguist-generated
7+
8+
# generated by Cargo
9+
rs/Cargo.toml linguist-generated

.github/workflows/rs-bench.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
- run: cargo install cargo-criterion
3636
working-directory: rs
3737
- run: cargo criterion
38+
env:
39+
AOC2023_DATADIR: ${{ github.workspace }}/inputs
3840
working-directory: rs
3941
- run: rsync --archive --delete --verbose --whole-file target/criterion/reports/ ../gh-docs/criterion/
4042
working-directory: rs

rs/benches/criterion.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use aoc2023::{day1, day2};
2-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2+
use criterion::{black_box, Criterion};
33
use std::env;
44
use std::fs;
55
use std::io;
@@ -25,8 +25,18 @@ fn aoc2023_bench(c: &mut Criterion) -> Result<(), io::Error> {
2525
g.bench_function("part 1", |b| b.iter(|| day2::part1(black_box(&data))));
2626
g.bench_function("part 2", |b| b.iter(|| day2::part2(black_box(&data))));
2727
g.finish();
28+
29+
Ok(())
30+
}
31+
32+
pub fn aoc2023() -> Result<(), io::Error> {
33+
let mut criterion = Criterion::default().configure_from_args();
34+
aoc2023_bench(&mut criterion)?;
2835
Ok(())
2936
}
3037

31-
criterion_group!(aoc2023, aoc2023_bench);
32-
criterion_main!(aoc2023);
38+
fn main() -> Result<(), io::Error> {
39+
aoc2023()?;
40+
Criterion::default().configure_from_args().final_summary();
41+
Ok(())
42+
}

0 commit comments

Comments
 (0)