Skip to content

Commit 3844734

Browse files
committed
arena: use the generic bh.iter to stop the benchmarks being DCE'd.
Before: test test::bench_nonpod_nonarena ... bench: 62 ns/iter (+/- 6) test test::bench_pod_nonarena ... bench: 0 ns/iter (+/- 0) After: test test::bench_nonpod_nonarena ... bench: 158 ns/iter (+/- 11) test test::bench_pod_nonarena ... bench: 48 ns/iter (+/- 2) The other tests show no change, but are adjusted to use the generic return value of `.iter` anyway so that this doesn't change in future.
1 parent b029a18 commit 3844734

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libarena/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -536,18 +536,18 @@ mod test {
536536
x: 1,
537537
y: 2,
538538
z: 3,
539-
});
539+
})
540540
})
541541
}
542542

543543
#[bench]
544544
pub fn bench_pod_nonarena(bh: &mut BenchHarness) {
545545
bh.iter(|| {
546-
let _ = ~Point {
546+
~Point {
547547
x: 1,
548548
y: 2,
549549
z: 3,
550-
};
550+
}
551551
})
552552
}
553553

@@ -561,7 +561,7 @@ mod test {
561561
y: 2,
562562
z: 3,
563563
}
564-
});
564+
})
565565
})
566566
}
567567

@@ -588,28 +588,28 @@ mod test {
588588
arena.alloc(Nonpod {
589589
string: ~"hello world",
590590
array: ~[ 1, 2, 3, 4, 5 ],
591-
});
591+
})
592592
})
593593
}
594594

595595
#[bench]
596596
pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) {
597597
bh.iter(|| {
598-
let _ = ~Nonpod {
598+
~Nonpod {
599599
string: ~"hello world",
600600
array: ~[ 1, 2, 3, 4, 5 ],
601-
};
601+
}
602602
})
603603
}
604604

605605
#[bench]
606606
pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) {
607607
let arena = Arena::new();
608608
bh.iter(|| {
609-
let _ = arena.alloc(|| Nonpod {
609+
arena.alloc(|| Nonpod {
610610
string: ~"hello world",
611611
array: ~[ 1, 2, 3, 4, 5 ],
612-
});
612+
})
613613
})
614614
}
615615
}

0 commit comments

Comments
 (0)