88
99#include "core.h"
1010
11+ #if defined(_MSC_VER )
12+ #define CODSPEED_NOINLINE __declspec(noinline)
13+ #else
14+ #define CODSPEED_NOINLINE __attribute__((noinline))
15+ #endif
16+
1117static int fib (int n ) {
1218 if (n <= 1 ) return n ;
1319 return fib (n - 1 ) + fib (n - 2 );
1420}
1521
1622static void expensive_setup (void ) { fib (30 ); }
1723
18- void example_function () {
24+ void example_function (void ) {
1925 // Simulate some work
2026 for (volatile int i = 0 ; i < 100000 ; i ++ )
2127 ;
2228 printf ("Benchmark executed\n" );
2329}
2430
25- int main () {
26- instrument_hooks_set_feature (FEATURE_DISABLE_CALLGRIND_MARKERS , true);
31+ CODSPEED_NOINLINE void __codspeed_root_frame__example (
32+ void (* benchmark_fn )(void )) {
33+ benchmark_fn ();
34+ }
2735
36+ int main () {
2837 InstrumentHooks * hooks = instrument_hooks_init ();
2938 if (!hooks ) {
3039 printf ("Failed to initialize instrument hooks\n" );
@@ -37,7 +46,7 @@ int main() {
3746 printf ("Not running under instrumentation\n" );
3847 }
3948
40- instrument_hooks_set_integration (hooks , "example " , "1.0.0" );
49+ instrument_hooks_set_integration (hooks , "custom-integration " , "1.0.0" );
4150
4251 printf ("Starting benchmark...\n" );
4352 if (instrument_hooks_start_benchmark_inline (hooks ) != 0 ) {
@@ -53,7 +62,7 @@ int main() {
5362 expensive_setup ();
5463
5564 uint64_t start_time = instrument_hooks_current_timestamp ();
56- example_function ( );
65+ __codspeed_root_frame__example ( example_function );
5766 uint64_t end_time = instrument_hooks_current_timestamp ();
5867
5968 // Add the markers which mark when the benchmarked function was running
0 commit comments