diff options
| author | Cheng XU <git@xuc.me> | 2021-08-28 19:46:58 -0700 |
|---|---|---|
| committer | Cheng XU <git@xuc.me> | 2021-08-28 19:46:58 -0700 |
| commit | 2ab73cf63d94d9ca0dc8a777813ad9339b3991f1 (patch) | |
| tree | 942e24760facddd2d74474c5e139aa55d2f3512c | |
| parent | 5eacec9ec7e112a0de1011519a57c45586d58414 (diff) | |
add benchmark for From<[T; N]> in VecDeque
| -rw-r--r-- | library/alloc/benches/vec_deque.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/library/alloc/benches/vec_deque.rs b/library/alloc/benches/vec_deque.rs index bf2dffd1e93..404cfa6addb 100644 --- a/library/alloc/benches/vec_deque.rs +++ b/library/alloc/benches/vec_deque.rs @@ -52,3 +52,18 @@ fn bench_try_fold(b: &mut Bencher) { b.iter(|| black_box(ring.iter().try_fold(0, |a, b| Some(a + b)))) } + +#[bench] +fn bench_from_array_1000(b: &mut Bencher) { + const N: usize = 1000; + let mut array: [usize; N] = [0; N]; + + for i in 0..N { + array[i] = i; + } + + b.iter(|| { + let deq: VecDeque<_> = array.into(); + black_box(deq); + }) +} |
