diff options
-rw-r--r-- | src/crates/benchmarker/src/lib.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/crates/benchmarker/src/lib.rs b/src/crates/benchmarker/src/lib.rs index 7f1a0f8..1a7d519 100644 --- a/src/crates/benchmarker/src/lib.rs +++ b/src/crates/benchmarker/src/lib.rs @@ -31,7 +31,9 @@ fn print_result(op: &str, n: usize, measurement: BenchmarkResult) { ) } -/// Benchmark an operation for approx 5 seconds, returning the results. +const TO_RUN: usize = 50; + +/// Benchmark an operation [`TO_RUN`] times, returning the results. /// /// `setup` is used to create the thing `op` acts on, and `undo` is called between each run to undo `op`. /// If `undo` is invalid, this will return garbage results. @@ -51,11 +53,14 @@ fn benchmark_op<T, R>( warmup_n += 1; } - let to_run = (warmup_n * (MEASUREMENT_TIME.as_millis() / WARM_UP_TIME.as_millis())) as usize; - let mut times = Vec::with_capacity(to_run); + println!( + "benchmarking for estimated {}ms", + (WARM_UP_TIME / warmup_n * TO_RUN as u32).as_millis() + ); + let mut times = Vec::with_capacity(TO_RUN); // Benchmarking loop - for _ in 0..to_run { + for _ in 0..TO_RUN { let mut target = black_box(setup()); let start = Instant::now(); |