Include the cost of shifts in insert/remove benchmarks (#268)

Thanks!
This commit is contained in:
Ben Kimock
2021-10-09 20:08:35 -04:00
committed by GitHub
parent 9af24f97df
commit 1403de85a2
+5 -6
View File
@@ -159,12 +159,11 @@ fn gen_insert<V: Vector<u64>>(n: u64, b: &mut Bencher) {
b.iter(|| {
let mut vec = V::new();
// Add one element, with each iteration we insert one before the end.
// This means that we benchmark the insertion operation and not the
// time it takes to `ptr::copy` the data.
// Always insert at position 0 so that we are subject to shifts of
// many different lengths.
vec.push(0);
for x in 0..n {
insert_noinline(&mut vec, x as _, x);
insert_noinline(&mut vec, 0, x);
}
vec
});
@@ -179,8 +178,8 @@ fn gen_remove<V: Vector<u64>>(n: usize, b: &mut Bencher) {
b.iter(|| {
let mut vec = V::from_elem(0, n as _);
for x in (0..n - 1).rev() {
remove_noinline(&mut vec, x);
for _ in 0..n {
remove_noinline(&mut vec, 0);
}
});
}