Search code examples
profilingprofilersampling

Profilers Instrumenting Vs Sampling


I am doing a study to between profilers mainly instrumenting and sampling. I have came up with the following info:

  • sampling: stop the execution of program, take PC and thus deduce were the program is
  • instrumenting: add some overhead code to the program so it would increment some pointers to know the program

If the above info is wrong correct me.

After this I was looking at the time of execution and some said that instrumenting takes more time than sampling! is this correct?

if yes why is that? in sampling you have to pay the price of context switching between processes while in the latter your in the same program no cost

Am i missing something?

cheers! =)


Solution

  • The interrupts generated by a sampling profiler generally add an insignficant amount of time to the total execution time, unless you have a very short sampling interval (e.g. < 1 ms).

    With instrumented profiling there can be a large overhead, e.g. on small leaf functions that get called many times, as the calls to the instrumentation library can be significant compared to the execution time of the function.