aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-03-08 17:22:53 +0000
committerAria Shrimpton <me@aria.rip>2024-03-08 17:22:53 +0000
commit167c3a17cf25a3b47c83a2bcc5788b0e5701e4fd (patch)
treec8d261a9f47ae576c8c17b796ed06b7a2ab7d177
parent0b2add103920fe97b9f27f6a3395632b94021b76 (diff)
fix some benchmark ops getting optimised out
-rw-r--r--src/crates/benchmarker/src/container.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/crates/benchmarker/src/container.rs b/src/crates/benchmarker/src/container.rs
index 4e7b12c..e071c5a 100644
--- a/src/crates/benchmarker/src/container.rs
+++ b/src/crates/benchmarker/src/container.rs
@@ -49,7 +49,7 @@ where
let mut c = T::default();
// decide where the element that we will search for will be
- let pivot = rng.gen_range(0..n);
+ let pivot = rng.gen_range(n / 4..n / 2 + n / 4);
// insert the element at pivot, and keep track of what it is
for _ in 0..pivot {
@@ -63,9 +63,7 @@ where
(c, chosen)
},
- |(c, search)| {
- c.contains(search);
- },
+ |(c, search)| c.contains(search),
);
print_results("contains", n, &results);
@@ -96,9 +94,7 @@ where
(c, chosen)
},
- |(c, remove)| {
- c.remove(*remove);
- },
+ |(c, remove)| c.remove(*remove),
);
print_results("remove", n, &results);
@@ -119,9 +115,7 @@ where
c
},
- |c| {
- c.clear();
- },
+ |c| c.clear(),
);
print_results("clear", n, &results);