Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions google_benchmark/src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,6 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
if (codspeed != nullptr) {
codspeed->start_benchmark(runner.GetBenchmarkName());
}

measurement_start();
#endif

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

#ifdef CODSPEED_WALLTIME
measurement_stop();

if (codspeed != nullptr) {
codspeed->end_benchmark();
}
Expand Down
11 changes: 11 additions & 0 deletions google_benchmark/src/benchmark_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,10 @@ void BenchmarkRunner::DoOneRepetition() {
manager.reset(new internal::ThreadManager(b.threads()));
internal::ThreadTimer timer = internal::ThreadTimer::Create();
b.Setup();
measurement_start();
State st = b.RunInstrumented(codspeed::CodSpeed::getInstance(), &timer,
manager.get(), nullptr, nullptr);
measurement_stop();
b.Teardown();

return;
Expand All @@ -486,6 +488,12 @@ void BenchmarkRunner::DoOneRepetition() {
RunWarmUp();
}

// IMPORTANT: We must not sample the warmup otherwise the flamegraph timings will be incorrect since we
// divide by the iteration count.
#ifdef CODSPEED_WALLTIME
measurement_start();
#endif

IterationResults i;
// We *may* be gradually increasing the length (iteration count)
// of the benchmark until we decide the results are significant.
Expand Down Expand Up @@ -519,6 +527,9 @@ void BenchmarkRunner::DoOneRepetition() {
"if we did more iterations than we want to do the next time, "
"then we should have accepted the current iteration run.");
}
#ifdef CODSPEED_WALLTIME
measurement_stop();
#endif

// Produce memory measurements if requested.
MemoryManager::Result* memory_result = nullptr;
Expand Down