cyclic in-place reuse bench
This commit is contained in:
parent
bb4f888a59
commit
8ac96e6a98
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user