This commit is contained in:
Ralf Jung 2022-11-07 15:24:49 +01:00
parent 780952f922
commit 29d451ccb3

View File

@ -29,10 +29,10 @@ fn bench_push_front_100(b: &mut test::Bencher) {
#[bench] #[bench]
fn bench_pop_back_100(b: &mut test::Bencher) { fn bench_pop_back_100(b: &mut test::Bencher) {
let size = 100; let size = 100;
let mut deq = VecDeque::<i32>::with_capacity(size+1); let mut deq = VecDeque::<i32>::with_capacity(size + 1);
// We'll mess with private state to pretend like `deq` is filled. // We'll mess with private state to pretend like `deq` is filled.
// Make sure the buffer is initialized so that we don't read uninit memory. // Make sure the buffer is initialized so that we don't read uninit memory.
unsafe { deq.ptr().write_bytes(0u8, size+1) }; unsafe { deq.ptr().write_bytes(0u8, size + 1) };
b.iter(|| { b.iter(|| {
deq.head = size; deq.head = size;
@ -72,17 +72,17 @@ fn bench_retain_half_10000(b: &mut test::Bencher) {
b.iter(|| { b.iter(|| {
let mut v = v.clone(); let mut v = v.clone();
v.retain(|x| *x > size/2) v.retain(|x| *x > size / 2)
}) })
} }
#[bench] #[bench]
fn bench_pop_front_100(b: &mut test::Bencher) { fn bench_pop_front_100(b: &mut test::Bencher) {
let size = 100; let size = 100;
let mut deq = VecDeque::<i32>::with_capacity(size+1); let mut deq = VecDeque::<i32>::with_capacity(size + 1);
// We'll mess with private state to pretend like `deq` is filled. // We'll mess with private state to pretend like `deq` is filled.
// Make sure the buffer is initialized so that we don't read uninit memory. // Make sure the buffer is initialized so that we don't read uninit memory.
unsafe { deq.ptr().write_bytes(0u8, size+1) }; unsafe { deq.ptr().write_bytes(0u8, size + 1) };
b.iter(|| { b.iter(|| {
deq.head = size; deq.head = size;