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.
This commit is contained in:
bluss
2018-11-25 16:34:47 +01:00
parent 91e88a4976
commit 23128275ee
+2 -1
View File
@@ -5,6 +5,7 @@ extern crate arrayvec;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use bencher::Bencher; use bencher::Bencher;
use bencher::black_box;
fn extend_with_constant(b: &mut Bencher) { fn extend_with_constant(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new(); let mut v = ArrayVec::<[u8; 512]>::new();
@@ -33,7 +34,7 @@ fn extend_with_slice(b: &mut Bencher) {
let data = [1; 512]; let data = [1; 512];
b.iter(|| { b.iter(|| {
v.clear(); v.clear();
v.extend(data.iter().cloned()); v.extend(black_box(data.iter()).cloned());
v[0] v[0]
}); });
b.bytes = v.capacity() as u64; b.bytes = v.capacity() as u64;