Šimon Tóth
Šimon Tóth

Reputation: 36451

GCC -finstrument-functions overhead

I'm looking for some performance test results for -finstrument-functions.

I'm considering to use it as a profiling tool and therefore I need to know if the overhead isn't too high (so it doesn't mangle the results).

Upvotes: 1

Views: 1615

Answers (1)

osgx
osgx

Reputation: 94345

The overhead is the 2 additional calls to instrumenting functions for each user function call.

It is just 3-5 * 2 asm instructions. Also, The instrumenting functions themselves

 __cyg_profile_func_enter 
 __cyg_profile_func_exit 

will consume time. But if you will to use plain -finstrument-functions, the code of cyg_profile functions is yours.

Even if function is inlined, the __cyg_profile* is still called. So, estimate the number of functions calls in target application and multiply to 40-100 cpu ticks of overhead for each call.

You may be interested in sampling profilers, like oprofile or linux kernel perf.

Upvotes: 4

Related Questions