diff options
| author | Paolo Barbolini <paolo@paolo565.org> | 2022-04-11 08:12:14 +0200 |
|---|---|---|
| committer | Paolo Barbolini <paolo@paolo565.org> | 2022-04-27 21:10:20 +0200 |
| commit | 84b8898d6357810472a01038bde7b1788615aa8a (patch) | |
| tree | a766f14bc6da16517d502846610bb4f608e7c073 | |
| parent | 69a5d2481e856a5a18885390b8cf6950b9ff8dd3 (diff) | |
| download | rust-84b8898d6357810472a01038bde7b1788615aa8a.tar.gz rust-84b8898d6357810472a01038bde7b1788615aa8a.zip | |
Add VecDeque::extend benchmark
| -rw-r--r-- | library/alloc/benches/vec_deque.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/library/alloc/benches/vec_deque.rs b/library/alloc/benches/vec_deque.rs index 404cfa6addb..6660380e4be 100644 --- a/library/alloc/benches/vec_deque.rs +++ b/library/alloc/benches/vec_deque.rs @@ -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)); + }); +} |
