Skip to content

Commit ec8d562

Browse files
committed
fix: dont sample warmup with perf
1 parent a34fdd1 commit ec8d562

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

google_benchmark/src/benchmark.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,14 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
573573
codspeed->start_benchmark(runner.GetBenchmarkName());
574574
}
575575

576-
measurement_start();
576+
// Only start measurement if warmup is done
577+
bool measurement_started = false;
578+
if (runner.IsWarmupDone()) {
579+
measurement_start();
580+
measurement_started = true;
581+
}
577582
#endif
578-
583+
579584
runner.DoOneRepetition();
580585
if (runner.HasRepeatsRemaining()) {
581586
continue;
@@ -605,7 +610,9 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
605610
}
606611

607612
#ifdef CODSPEED_WALLTIME
608-
measurement_stop();
613+
if (measurement_started) {
614+
measurement_stop();
615+
}
609616

610617
if (codspeed != nullptr) {
611618
codspeed->end_benchmark();

google_benchmark/src/benchmark_runner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class BenchmarkRunner {
7474

7575
IterationCount GetIters() const { return iters; }
7676

77+
bool IsWarmupDone() const { return warmup_done; }
78+
7779
private:
7880
RunResults run_results;
7981

0 commit comments

Comments
 (0)