Skip to content

Commit 1cac95e

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

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

google_benchmark/src/benchmark.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,6 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
572572
if (codspeed != nullptr) {
573573
codspeed->start_benchmark(runner.GetBenchmarkName());
574574
}
575-
576-
measurement_start();
577575
#endif
578576

579577
runner.DoOneRepetition();
@@ -605,8 +603,6 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
605603
}
606604

607605
#ifdef CODSPEED_WALLTIME
608-
measurement_stop();
609-
610606
if (codspeed != nullptr) {
611607
codspeed->end_benchmark();
612608
}

google_benchmark/src/benchmark_runner.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,10 @@ void BenchmarkRunner::DoOneRepetition() {
466466
manager.reset(new internal::ThreadManager(b.threads()));
467467
internal::ThreadTimer timer = internal::ThreadTimer::Create();
468468
b.Setup();
469+
measurement_start();
469470
State st = b.RunInstrumented(codspeed::CodSpeed::getInstance(), &timer,
470471
manager.get(), nullptr, nullptr);
472+
measurement_stop();
471473
b.Teardown();
472474

473475
return;
@@ -486,6 +488,12 @@ void BenchmarkRunner::DoOneRepetition() {
486488
RunWarmUp();
487489
}
488490

491+
// IMPORTANT: We must not sample the warmup otherwise the flamegraph timings will be incorrect since we
492+
// divide by the iteration count.
493+
#ifdef CODSPEED_WALLTIME
494+
measurement_start();
495+
#endif
496+
489497
IterationResults i;
490498
// We *may* be gradually increasing the length (iteration count)
491499
// of the benchmark until we decide the results are significant.
@@ -519,6 +527,9 @@ void BenchmarkRunner::DoOneRepetition() {
519527
"if we did more iterations than we want to do the next time, "
520528
"then we should have accepted the current iteration run.");
521529
}
530+
#ifdef CODSPEED_WALLTIME
531+
measurement_stop();
532+
#endif
522533

523534
// Produce memory measurements if requested.
524535
MemoryManager::Result* memory_result = nullptr;

0 commit comments

Comments
 (0)