Skip to content

Commit 2312827

Browse files
committed
TEST: Update benchmark for extend_from_slice
The benchmark was optimized out totally. We think of that as a good sign, the new extend became transparent to the compiler and we had to get smarter in how to fool it.
1 parent 91e88a4 commit 2312827

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

benches/extend.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern crate arrayvec;
55
use arrayvec::ArrayVec;
66

77
use bencher::Bencher;
8+
use bencher::black_box;
89

910
fn extend_with_constant(b: &mut Bencher) {
1011
let mut v = ArrayVec::<[u8; 512]>::new();
@@ -33,7 +34,7 @@ fn extend_with_slice(b: &mut Bencher) {
3334
let data = [1; 512];
3435
b.iter(|| {
3536
v.clear();
36-
v.extend(data.iter().cloned());
37+
v.extend(black_box(data.iter()).cloned());
3738
v[0]
3839
});
3940
b.bytes = v.capacity() as u64;

0 commit comments

Comments
 (0)