Skip to content

Commit

Permalink
TEST: add benchmark for extend_from_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Nov 26, 2018
1 parent c4b6e86 commit 8a8332f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion benches/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 8a8332f

Please sign in to comment.