Skip to content

Commit 2ab73cf

Browse files
committedAug 29, 2021
add benchmark for From<[T; N]> in VecDeque
1 parent 5eacec9 commit 2ab73cf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎library/alloc/benches/vec_deque.rs

+15
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,18 @@ fn bench_try_fold(b: &mut Bencher) {
5252

5353
b.iter(|| black_box(ring.iter().try_fold(0, |a, b| Some(a + b))))
5454
}
55+
56+
#[bench]
57+
fn bench_from_array_1000(b: &mut Bencher) {
58+
const N: usize = 1000;
59+
let mut array: [usize; N] = [0; N];
60+
61+
for i in 0..N {
62+
array[i] = i;
63+
}
64+
65+
b.iter(|| {
66+
let deq: VecDeque<_> = array.into();
67+
black_box(deq);
68+
})
69+
}

0 commit comments

Comments
 (0)
Please sign in to comment.