Add VecDeque::extend TrustedLen benchmark
This commit is contained in:
parent
0cb9899e78
commit
ac2c21a623
@ -91,3 +91,35 @@ fn bench_extend_vec(b: &mut Bencher) {
|
|||||||
ring.extend(black_box(input));
|
ring.extend(black_box(input));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_extend_trustedlen(b: &mut Bencher) {
|
||||||
|
let mut ring: VecDeque<u16> = VecDeque::with_capacity(1000);
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
ring.clear();
|
||||||
|
ring.extend(black_box(0..512));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_extend_chained_trustedlen(b: &mut Bencher) {
|
||||||
|
let mut ring: VecDeque<u16> = VecDeque::with_capacity(1000);
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
ring.clear();
|
||||||
|
ring.extend(black_box((0..256).chain(768..1024)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_extend_chained_bytes(b: &mut Bencher) {
|
||||||
|
let mut ring: VecDeque<u16> = VecDeque::with_capacity(1000);
|
||||||
|
let input1: &[u16] = &[128; 256];
|
||||||
|
let input2: &[u16] = &[255; 256];
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
ring.clear();
|
||||||
|
ring.extend(black_box(input1.iter().chain(input2.iter())));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user