From 167c3a17cf25a3b47c83a2bcc5788b0e5701e4fd Mon Sep 17 00:00:00 2001 From: Aria Shrimpton Date: Fri, 8 Mar 2024 17:22:53 +0000 Subject: fix some benchmark ops getting optimised out --- src/crates/benchmarker/src/container.rs | 14 ++++---------- 1 file 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); -- cgit v1.2.3