Skip to content

Commit

Permalink
Improve benchmarking stability
Browse files Browse the repository at this point in the history
Run all the paths in a single callback to avoid confusing `.iter`.

Right now we have only one path either way, so this doesn't change much, but better to have a safeguard for the future.
  • Loading branch information
RReverser committed Mar 20, 2019
1 parent e8e9b91 commit d775438
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ fn bench_parsing_reuse_parser(bencher: &mut bencher::Bencher) {
}

fn bench_parsing_aux(parser: Option<&Shift>, bencher: &mut bencher::Bencher) {
for &path in PATHS {
bencher.iter(move || {
bencher.iter(move || {
for &path in PATHS {
let shift;

match parser {
Some(parser) => parser,
None => {
shift = launch_shift();
&shift
bencher::black_box(
match parser {
Some(parser) => parser,
None => {
shift = launch_shift();
&shift
}
}
}
.parse_file(path)
.expect("Could not parse source")
});
}
.parse_file(path)
.expect("Could not parse source"),
);
}
});
}

benchmark_group!(
Expand Down

0 comments on commit d775438

Please sign in to comment.