@@ -135,14 +135,14 @@ BenchmarkReporter::Run CreateRunReport(
135135void RunInThread (const BenchmarkInstance* b, IterationCount iters,
136136 int thread_id, ThreadManager* manager,
137137 PerfCountersMeasurement* perf_counters_measurement,
138- ProfilerManager* profiler_manager_) {
138+ ProfilerManager* profiler_manager_, bool is_warmup = false ) {
139139 internal::ThreadTimer timer (
140140 b->measure_process_cpu_time ()
141141 ? internal::ThreadTimer::CreateProcessCpuTime ()
142142 : internal::ThreadTimer::Create ());
143143
144144 State st = b->__codspeed_root_frame__Run (iters, thread_id, &timer, manager,
145- perf_counters_measurement, profiler_manager_);
145+ perf_counters_measurement, profiler_manager_, is_warmup );
146146 BM_CHECK (st.skipped () || st.iterations () >= st.max_iterations )
147147 << " Benchmark returned before State::KeepRunning() returned false!" ;
148148 {
@@ -285,7 +285,7 @@ BenchmarkRunner::BenchmarkRunner(
285285 }
286286}
287287
288- BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations () {
288+ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations (bool is_warmup ) {
289289 BM_VLOG (2 ) << " Running " << b.name ().str () << " for " << iters << " \n " ;
290290
291291 std::unique_ptr<internal::ThreadManager> manager;
@@ -295,13 +295,13 @@ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations() {
295295 for (std::size_t ti = 0 ; ti < pool.size (); ++ti) {
296296 pool[ti] = std::thread (&RunInThread, &b, iters, static_cast <int >(ti + 1 ),
297297 manager.get (), perf_counters_measurement_ptr,
298- /* profiler_manager=*/ nullptr );
298+ /* profiler_manager=*/ nullptr , is_warmup );
299299 }
300300 // And run one thread here directly.
301301 // (If we were asked to run just one thread, we don't create new threads.)
302302 // Yes, we need to do this here *after* we start the separate threads.
303303 RunInThread (&b, iters, 0 , manager.get (), perf_counters_measurement_ptr,
304- /* profiler_manager=*/ nullptr );
304+ /* profiler_manager=*/ nullptr , is_warmup );
305305
306306 // The main thread has finished. Now let's wait for the other threads.
307307 manager->WaitForAllThreads ();
@@ -405,7 +405,7 @@ void BenchmarkRunner::RunWarmUp() {
405405
406406 for (;;) {
407407 b.Setup ();
408- i_warmup = DoNIterations ();
408+ i_warmup = DoNIterations (/* is_warmup= */ true );
409409 b.Teardown ();
410410
411411 const bool finish = ShouldReportIterationResults (i_warmup);
@@ -486,12 +486,6 @@ void BenchmarkRunner::DoOneRepetition() {
486486 RunWarmUp ();
487487 }
488488
489- // IMPORTANT: We must not sample the warmup otherwise the flamegraph timings will be incorrect since we
490- // divide by the iteration count.
491- #ifdef CODSPEED_WALLTIME
492- measurement_start ();
493- #endif
494-
495489 IterationResults i;
496490 // We *may* be gradually increasing the length (iteration count)
497491 // of the benchmark until we decide the results are significant.
@@ -525,9 +519,6 @@ void BenchmarkRunner::DoOneRepetition() {
525519 " if we did more iterations than we want to do the next time, "
526520 " then we should have accepted the current iteration run." );
527521 }
528- #ifdef CODSPEED_WALLTIME
529- measurement_stop ();
530- #endif
531522
532523 // Produce memory measurements if requested.
533524 MemoryManager::Result* memory_result = nullptr ;
0 commit comments