1
Fork 0

Fix the bench_max and bench_max_by_key benchmarks

This commit is contained in:
Tim Vermeulen 2019-03-12 17:52:10 +01:00
parent 88f755f8a8
commit 8d18e57b8a

View file

@ -35,7 +35,7 @@ fn scatter(x: i32) -> i32 { (x * 31) % 127 }
fn bench_max_by_key(b: &mut Bencher) { fn bench_max_by_key(b: &mut Bencher) {
b.iter(|| { b.iter(|| {
let it = 0..100; let it = 0..100;
it.max_by_key(|&x| scatter(x)) it.map(black_box).max_by_key(|&x| scatter(x))
}) })
} }
@ -56,7 +56,7 @@ fn bench_max_by_key2(b: &mut Bencher) {
fn bench_max(b: &mut Bencher) { fn bench_max(b: &mut Bencher) {
b.iter(|| { b.iter(|| {
let it = 0..100; let it = 0..100;
it.map(scatter).max() it.map(black_box).map(scatter).max()
}) })
} }