Skip to content

Commit

Permalink
Add missing black_box for bench_with_input parameters. Fixes 566.
Browse files Browse the repository at this point in the history
  • Loading branch information
bheisler committed Jul 15, 2022
1 parent ecfd1d1 commit 2934163
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Formal support for benchmarking code compiled to web-assembly.
- A `--quiet` flag for printing just a single line per benchmark.

### Fixed
- When using `bench_with_input`, the input parameter will now be passed through `black_box` before
passing it to the benchmark.

## [0.3.5] - 2021-07-26

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions src/routine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::benchmark::BenchmarkConfig;
use crate::connection::OutgoingMessage;
use crate::measurement::Measurement;
use crate::report::{BenchmarkId, Report, ReportContext};
use crate::{ActualSamplingMode, Bencher, Criterion};
use crate::{black_box, ActualSamplingMode, Bencher, Criterion};
use std::marker::PhantomData;
use std::time::Duration;

Expand Down Expand Up @@ -247,7 +247,7 @@ where
.iter()
.map(|iters| {
b.iters = *iters;
(*f)(&mut b, parameter);
(*f)(&mut b, black_box(parameter));
b.assert_iterated();
m.to_f64(&b.value)
})
Expand All @@ -267,7 +267,7 @@ where
let mut total_iters = 0;
let mut elapsed_time = Duration::from_millis(0);
loop {
(*f)(&mut b, parameter);
(*f)(&mut b, black_box(parameter));

b.assert_iterated();

Expand Down

0 comments on commit 2934163

Please sign in to comment.