1

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).

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
  • If you want to make the code faster, [consider this method.](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024) Instrumenting functions is a popular but not very good way to do it. – Mike Dunlavey Jun 23 '11 at 12:53

1 Answers1

4

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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
osgx
  • 90,338
  • 53
  • 357
  • 513