Add VecDeque::extend benchmark

This commit is contained in:
Paolo Barbolini 2022-04-11 08:12:14 +02:00
parent 69a5d2481e
commit 84b8898d63

View File

@ -67,3 +67,27 @@ fn bench_from_array_1000(b: &mut Bencher) {
black_box(deq);
})
}
#[bench]
fn bench_extend_bytes(b: &mut Bencher) {
let mut ring: VecDeque<u8> = VecDeque::with_capacity(1000);
let input: &[u8] = &[128; 512];
b.iter(|| {
ring.clear();
ring.extend(black_box(input));
});
}
#[bench]
fn bench_extend_vec(b: &mut Bencher) {
let mut ring: VecDeque<u8> = VecDeque::with_capacity(1000);
let input = vec![128; 512];
b.iter(|| {
ring.clear();
let input = input.clone();
ring.extend(black_box(input));
});
}