Skip to content

Commit 696eaa1

Browse files
committed
fix: exclude paused sections from instrumentation measurement
PauseTiming/ResumeTiming now stop/start Callgrind instrumentation in CODSPEED_ANALYSIS mode, ensuring setup/teardown code is not included in benchmark measurements.
1 parent d6b4111 commit 696eaa1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

google_benchmark/src/benchmark.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "codspeed.h"
2020
#include "internal_macros.h"
2121

22-
#ifdef CODSPEED_WALLTIME
22+
#if defined(CODSPEED_WALLTIME) || defined(CODSPEED_ANALYSIS)
2323
#include "measurement.hpp"
2424
#endif
2525

@@ -272,6 +272,9 @@ void State::PauseTiming() {
272272
#ifdef CODSPEED_WALLTIME
273273
uint64_t pause_timestamp = measurement_current_timestamp();
274274
#endif
275+
#ifdef CODSPEED_ANALYSIS
276+
callgrind_stop_instrumentation();
277+
#endif
275278

276279
// Add in time accumulated so far
277280
BM_CHECK(started_ && !finished_ && !skipped());
@@ -310,6 +313,9 @@ void State::ResumeTiming() {
310313
BM_CHECK(resume_timestamp_ == 0);
311314
resume_timestamp_ = measurement_current_timestamp();
312315
#endif
316+
#ifdef CODSPEED_ANALYSIS
317+
callgrind_start_instrumentation();
318+
#endif
313319
}
314320

315321
void State::SkipWithMessage(const std::string& msg) {

0 commit comments

Comments
 (0)