mirror of
https://github.com/openharmony/third_party_rust_rust-smallvec.git
synced 2026-07-19 23:03:32 -04:00
+5
-6
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user