cyclic in-place reuse bench

This commit is contained in:
The8472 2019-11-20 23:37:50 +01:00
parent bb4f888a59
commit 8ac96e6a98

View File

@ -481,6 +481,26 @@ bench_in_place![
bench_in_place_u128_i1_1000, u128, 1000, 1
];
#[bench]
fn bench_in_place_recycle(b: &mut test::Bencher) {
let mut data = vec![0; 1000];
b.iter(|| {
let tmp = std::mem::replace(&mut data, Vec::new());
std::mem::replace(
&mut data,
black_box(
tmp.into_iter()
.enumerate()
.map(|(idx, e)| idx.wrapping_add(e))
.fuse()
.peekable()
.collect::<Vec<usize>>(),
),
);
});
}
#[bench]
fn bench_chain_collect(b: &mut test::Bencher) {
let data = black_box([0; LEN]);