add benchmark
This commit is contained in:
parent
fd0a3313f7
commit
cfb0f11a9f
@ -1,3 +1,4 @@
|
||||
use core::ptr::NonNull;
|
||||
use test::black_box;
|
||||
use test::Bencher;
|
||||
|
||||
@ -162,3 +163,11 @@ fn fill_byte_sized(b: &mut Bencher) {
|
||||
black_box(slice.fill(black_box(NewType(42))));
|
||||
});
|
||||
}
|
||||
|
||||
// Tests the ability of the compiler to recognize that only the last slice item is needed
|
||||
// based on issue #106288
|
||||
#[bench]
|
||||
fn fold_to_last(b: &mut Bencher) {
|
||||
let slice: &[i32] = &[0; 1024];
|
||||
b.iter(|| black_box(slice).iter().fold(None, |_, r| Some(NonNull::from(r))));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user