@@ -16,12 +16,12 @@ extern "C" {
1616#include " core.h"
1717}
1818
19- inline InstrumentHooks* get_hooks () {
20- static InstrumentHooks* g_hooks = nullptr ;
19+ static InstrumentHooks* g_hooks = nullptr ;
20+
21+ inline void measurement_init () {
2122 if (!g_hooks) {
2223 g_hooks = instrument_hooks_init ();
2324 }
24- return g_hooks;
2525}
2626
2727inline std::string get_version () {
@@ -34,36 +34,40 @@ inline std::string get_version() {
3434
3535#ifdef CODSPEED_INSTRUMENTATION
3636inline bool measurement_is_instrumented () {
37- return instrument_hooks_is_instrumented (get_hooks () );
37+ return instrument_hooks_is_instrumented (g_hooks );
3838}
3939
4040inline void measurement_set_metadata () {
4141 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 ());
4443}
4544
4645__attribute__ ((always_inline)) inline void measurement_start() {
47- instrument_hooks_start_benchmark ( get_hooks () );
46+ instrument_hooks_start_benchmark_inline (g_hooks );
4847}
4948
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+ }
5352
53+ __attribute__ ((always_inline)) inline void measurement_executed_benchmark(
54+ const std::string& name) {
5455#ifdef _WIN32
5556 auto current_pid = _getpid ();
5657#else
5758 auto current_pid = getpid ();
5859#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+ }
6162#else
6263// Stub implementations for non-instrumentation builds
6364inline bool measurement_is_instrumented () { return false ; }
6465inline void measurement_set_metadata () {}
6566inline 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+ }
6771#endif
6872
6973#endif // MEASUREMENT_H
0 commit comments