Skip to content

Commit

Permalink
Include the cost of shifts in insert/remove benchmarks (#268)
Browse files Browse the repository at this point in the history
Thanks!
  • Loading branch information
saethlin authored Oct 10, 2021
1 parent 58edc0e commit 5ae217a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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);
}
});
}
Expand Down

0 comments on commit 5ae217a

Please sign in to comment.