@@ -16,12 +16,12 @@ extern "C" {
16
16
#include " core.h"
17
17
}
18
18
19
- inline InstrumentHooks* get_hooks () {
20
- static InstrumentHooks* g_hooks = nullptr ;
19
+ static InstrumentHooks* g_hooks = nullptr ;
20
+
21
+ inline void measurement_init () {
21
22
if (!g_hooks) {
22
23
g_hooks = instrument_hooks_init ();
23
24
}
24
- return g_hooks;
25
25
}
26
26
27
27
inline std::string get_version () {
@@ -34,36 +34,40 @@ inline std::string get_version() {
34
34
35
35
#ifdef CODSPEED_INSTRUMENTATION
36
36
inline bool measurement_is_instrumented () {
37
- return instrument_hooks_is_instrumented (get_hooks () );
37
+ return instrument_hooks_is_instrumented (g_hooks );
38
38
}
39
39
40
40
inline void measurement_set_metadata () {
41
41
std::string version = get_version ();
42
- instrument_hooks_set_integration (get_hooks (), " codspeed-cpp" ,
43
- version.c_str ());
42
+ instrument_hooks_set_integration (g_hooks, " codspeed-cpp" , version.c_str ());
44
43
}
45
44
46
45
__attribute__ ((always_inline)) inline void measurement_start() {
47
- instrument_hooks_start_benchmark ( get_hooks () );
46
+ instrument_hooks_start_benchmark_inline (g_hooks );
48
47
}
49
48
50
- __attribute__ ((always_inline)) inline void measurement_stop(
51
- const std::string& name) {
52
- instrument_hooks_stop_benchmark ( get_hooks ());
49
+ __attribute__ ((always_inline)) inline void measurement_stop() {
50
+ instrument_hooks_stop_benchmark_inline (g_hooks);
51
+ }
53
52
53
+ __attribute__ ((always_inline)) inline void measurement_executed_benchmark(
54
+ const std::string& name) {
54
55
#ifdef _WIN32
55
56
auto current_pid = _getpid ();
56
57
#else
57
58
auto current_pid = getpid ();
58
59
#endif
59
- instrument_hooks_executed_benchmark (get_hooks () , current_pid, name.c_str ());
60
- };
60
+ instrument_hooks_executed_benchmark (g_hooks , current_pid, name.c_str ());
61
+ }
61
62
#else
62
63
// Stub implementations for non-instrumentation builds
63
64
inline bool measurement_is_instrumented () { return false ; }
64
65
inline void measurement_set_metadata () {}
65
66
inline void measurement_start () {}
66
- inline void measurement_stop (const std::string& name) { (void )name; }
67
+ inline void measurement_stop () {}
68
+ inline void measurement_executed_benchmark (const std::string& name) {
69
+ (void )name;
70
+ }
67
71
#endif
68
72
69
73
#endif // MEASUREMENT_H
0 commit comments