Skip to content

Commit 0af68cb

Browse files
committed
fix: resume and pause timing before measurements
If we don't do this at the right place, we'll get increased timings for smaller benchmarks.
1 parent f5508f8 commit 0af68cb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

google_benchmark/include/benchmark/benchmark.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,16 +1065,16 @@ struct State::StateIterator {
10651065
bool operator!=(StateIterator const&) const {
10661066
if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) return true;
10671067

1068-
10691068
#if defined(CODSPEED_INSTRUMENTATION)
10701069
measurement_stop();
1070+
#endif
1071+
parent_->FinishKeepRunning();
10711072

1073+
#if defined(CODSPEED_INSTRUMENTATION)
10721074
if (parent_->codspeed_ != NULL) {
10731075
parent_->codspeed_->end_benchmark();
10741076
}
10751077
#endif
1076-
1077-
parent_->FinishKeepRunning();
10781078
return false;
10791079
}
10801080

@@ -1087,13 +1087,15 @@ inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::begin() {
10871087
return StateIterator(this);
10881088
}
10891089
inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end() {
1090-
StartKeepRunning();
1091-
10921090
#ifdef CODSPEED_INSTRUMENTATION
10931091
if (this->codspeed_ != NULL) {
10941092
this->codspeed_->start_benchmark(name_);
10951093
}
1094+
#endif
1095+
1096+
StartKeepRunning();
10961097

1098+
#ifdef CODSPEED_INSTRUMENTATION
10971099
measurement_start();
10981100
#endif
10991101

0 commit comments

Comments
 (0)