Skip to content

Commit 035e4bc

Browse files
committed
chore: create new function to set executed benchmark
1 parent 6ed891b commit 035e4bc

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

core/include/measurement.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,30 @@ __attribute__((always_inline)) inline void measurement_start() {
5252
CALLGRIND_START_INSTRUMENTATION;
5353
}
5454

55-
__attribute__((always_inline)) inline void measurement_stop(
56-
const std::string& name) {
55+
__attribute__((always_inline)) inline void measurement_stop() {
5756
CALLGRIND_STOP_INSTRUMENTATION;
57+
5858
instrument_hooks_stop_benchmark(get_hooks());
59+
};
5960

61+
__attribute__((noinline)) inline void measurement_set_executed(
62+
const std::string& name) {
6063
#ifdef _WIN32
6164
auto current_pid = _getpid();
6265
#else
6366
auto current_pid = getpid();
6467
#endif
68+
6569
instrument_hooks_executed_benchmark(get_hooks(), current_pid, name.c_str());
66-
};
70+
}
71+
6772
#else
6873
// Stub implementations for non-instrumentation builds
6974
inline bool measurement_is_instrumented() { return false; }
7075
inline void measurement_set_metadata() {}
7176
inline void measurement_start() {}
72-
inline void measurement_stop(const std::string& name) { (void)name; }
77+
inline void measurement_stop() {}
78+
inline void measurement_set_executed(const std::string& name) { (void)name; }
7379
#endif
7480

7581
#endif // MEASUREMENT_H

core/src/codspeed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void CodSpeed::start_benchmark(const std::string &name) {
8585
}
8686

8787
void CodSpeed::end_benchmark() {
88-
measurement_stop(current_benchmark);
88+
measurement_set_executed(current_benchmark);
8989
benchmarked.push_back(current_benchmark);
9090
std::string action_str = is_instrumented ? "Measured" : "Checked";
9191
std::string group_str =

google_benchmark/include/benchmark/benchmark.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ struct State::StateIterator {
10661066
if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) return true;
10671067
#ifdef CODSPEED_INSTRUMENTATION
10681068
if (parent_->codspeed_ != NULL) {
1069+
measurement_stop();
10691070
parent_->codspeed_->end_benchmark();
10701071
}
10711072
#endif

0 commit comments

Comments
 (0)