Rejig the `StaticHeap` benchmark a bit
@@ -21,12 +21,13 @@ fn staticheap_push_random_u64_512(b: &mut Bencher) {
.unwrap()
.as_nanos(),
);
- let vec = StaticVec::<u64, 512>::filled_with(|| rng.rand_u64());
- b.iter(|| {
+ let vec = StaticVec::<u64, 512>::filled_with(|| rng.rand_range(1..769));
let mut heap = StaticHeap::<u64, 512>::new();
+ b.iter(|| {
for item in &vec {
heap.push(*item);
}
+ heap.clear();
});
}
@@ -38,12 +39,13 @@ fn staticheap_push_random_u64_1024(b: &mut Bencher) {
.unwrap()
.as_nanos(),
);
- let vec = StaticVec::<u64, 1024>::filled_with(|| rng.rand_u64());
- b.iter(|| {
+ let vec = StaticVec::<u64, 1024>::filled_with(|| rng.rand_range(1..1537));
let mut heap = StaticHeap::<u64, 1024>::new();
+ b.iter(|| {
for item in &vec {
heap.push(*item);
}
+ heap.clear();
});
}
@@ -55,12 +57,13 @@ fn staticheap_push_random_u64_2048(b: &mut Bencher) {
.unwrap()
.as_nanos(),
);
- let vec = StaticVec::<u64, 2048>::filled_with(|| rng.rand_u64());
- b.iter(|| {
+ let vec = StaticVec::<u64, 2048>::filled_with(|| rng.rand_range(1..3073));
let mut heap = StaticHeap::<u64, 2048>::new();
+ b.iter(|| {
for item in &vec {
heap.push(*item);
}
+ heap.clear();
});
}
@@ -72,12 +75,13 @@ fn staticheap_push_random_u64_4096(b: &mut Bencher) {
.unwrap()
.as_nanos(),
);
- let vec = StaticVec::<u64, 4096>::filled_with(|| rng.rand_u64());
- b.iter(|| {
+ let vec = StaticVec::<u64, 4096>::filled_with(|| rng.rand_range(1..6145));
let mut heap = StaticHeap::<u64, 4096>::new();
+ b.iter(|| {
for item in &vec {
heap.push(*item);
}
+ heap.clear();
});
}
@@ -89,11 +93,12 @@ fn staticheap_push_random_u64_8192(b: &mut Bencher) {
.unwrap()
.as_nanos(),
);
- let vec = StaticVec::<u64, 8192>::filled_with(|| rng.rand_u64());
- b.iter(|| {
+ let vec = StaticVec::<u64, 8192>::filled_with(|| rng.rand_range(1..12289));
let mut heap = StaticHeap::<u64, 8192>::new();
+ b.iter(|| {
for item in &vec {
heap.push(*item);
}
+ heap.clear();
});
}
