Skip to content

Commit acb2c32

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 acb2c32

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

google_benchmark/include/benchmark/benchmark.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,6 @@ struct State::StateIterator {
10741074
if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) {
10751075
return true;
10761076
}
1077-
#ifdef CODSPEED_ANALYSIS
1078-
measurement_stop();
1079-
#endif
10801077
parent_->FinishKeepRunning();
10811078

10821079
#ifdef CODSPEED_ANALYSIS
@@ -1103,9 +1100,6 @@ inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end() {
11031100
#endif
11041101

11051102
StartKeepRunning();
1106-
#ifdef CODSPEED_ANALYSIS
1107-
measurement_start();
1108-
#endif
11091103
return StateIterator();
11101104
}
11111105

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+
measurement_stop();
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+
measurement_start();
318+
#endif
313319
}
314320

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

0 commit comments

Comments
 (0)