From 8a8332f8864d6f1a400ef3a243da9843ee6f92ff Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Mon, 26 Nov 2018 13:06:06 +0100 Subject: [PATCH] TEST: add benchmark for extend_from_slice --- benches/extend.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/benches/extend.rs b/benches/extend.rs index 0ae7ce32..fe9fd967 100644 --- a/benches/extend.rs +++ b/benches/extend.rs @@ -40,5 +40,16 @@ fn extend_with_slice(b: &mut Bencher) { 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);