bench in-place collect of droppables

This commit is contained in:
The8472 2019-11-21 00:06:31 +01:00
parent 8ac96e6a98
commit a9c78e371e
1 changed files with 15 additions and 0 deletions

View File

@ -501,6 +501,21 @@ fn bench_in_place_recycle(b: &mut test::Bencher) {
}); });
} }
#[derive(Clone)]
struct Droppable(usize);
impl Drop for Droppable {
fn drop(&mut self) {
black_box(self);
}
}
#[bench]
fn bench_in_place_collect_droppable(b: &mut test::Bencher) {
let v: Vec<Droppable> = std::iter::repeat_with(|| Droppable(0)).take(1000).collect();
b.iter(|| v.clone().into_iter().skip(100).collect::<Vec<_>>())
}
#[bench] #[bench]
fn bench_chain_collect(b: &mut test::Bencher) { fn bench_chain_collect(b: &mut test::Bencher) {
let data = black_box([0; LEN]); let data = black_box([0; LEN]);