Skip to content

Commit

Permalink
Fix criterion.rs runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient committed Dec 2, 2023
1 parent e025f14 commit 2968c34
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# generated by Gradle Wrapper
kt/gradlew linguist-generated
kt/gradlew.bat linguist-generated

# generated by Poetry
py/poetry.lock linguist-generated

# generated by Cargo
rs/Cargo.toml linguist-generated
2 changes: 2 additions & 0 deletions .github/workflows/rs-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- run: cargo install cargo-criterion
working-directory: rs
- run: cargo criterion
env:
AOC2023_DATADIR: ${{ github.workspace }}/inputs
working-directory: rs
- run: rsync --archive --delete --verbose --whole-file target/criterion/reports/ ../gh-docs/criterion/
working-directory: rs
Expand Down
16 changes: 13 additions & 3 deletions rs/benches/criterion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aoc2023::{day1, day2};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{black_box, Criterion};
use std::env;
use std::fs;
use std::io;
Expand All @@ -25,8 +25,18 @@ fn aoc2023_bench(c: &mut Criterion) -> Result<(), io::Error> {
g.bench_function("part 1", |b| b.iter(|| day2::part1(black_box(&data))));
g.bench_function("part 2", |b| b.iter(|| day2::part2(black_box(&data))));
g.finish();

Ok(())
}

pub fn aoc2023() -> Result<(), io::Error> {
let mut criterion = Criterion::default().configure_from_args();
aoc2023_bench(&mut criterion)?;
Ok(())
}

criterion_group!(aoc2023, aoc2023_bench);
criterion_main!(aoc2023);
fn main() -> Result<(), io::Error> {
aoc2023()?;
Criterion::default().configure_from_args().final_summary();
Ok(())
}

0 comments on commit 2968c34

Please sign in to comment.