Skip to content

Commit 7a92590

Browse files
committed
Add warm-up to runtime benchmark execution
1 parent c0cb27e commit 7a92590

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

collector/benchlib/src/benchmark.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ impl BenchmarkGroup {
8080

8181
for (name, benchmark_fn) in items {
8282
let mut stats: Vec<BenchmarkStats> = Vec::with_capacity(args.iterations as usize);
83+
// Warm-up
84+
for _ in 0..3 {
85+
let benchmark_stats = benchmark_fn()?;
86+
black_box(benchmark_stats);
87+
}
88+
89+
// Actual measurement
8390
for i in 0..args.iterations {
8491
let benchmark_stats = benchmark_fn()?;
8592
log::info!("Benchmark (run {i}) `{name}` completed: {benchmark_stats:?}");

0 commit comments

Comments
 (0)