TEST: add benchmark for extend_from_slice
This commit is contained in:
+12
-1
@@ -40,5 +40,16 @@ fn extend_with_slice(b: &mut Bencher) {
|
|||||||
b.bytes = v.capacity() as u64;
|
b.bytes = v.capacity() as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
benchmark_group!(benches, extend_with_constant, extend_with_range, extend_with_slice);
|
fn extend_with_slice_fn(b: &mut Bencher) {
|
||||||
|
let mut v = ArrayVec::<[u8; 512]>::new();
|
||||||
|
let data = [1; 512];
|
||||||
|
b.iter(|| {
|
||||||
|
v.clear();
|
||||||
|
black_box(v.extend_from_slice(&data));
|
||||||
|
v[0]
|
||||||
|
});
|
||||||
|
b.bytes = v.capacity() as u64;
|
||||||
|
}
|
||||||
|
|
||||||
|
benchmark_group!(benches, extend_with_constant, extend_with_range, extend_with_slice, extend_with_slice_fn);
|
||||||
benchmark_main!(benches);
|
benchmark_main!(benches);
|
||||||
|
|||||||
Reference in New Issue
Block a user