How exactly does gprof work?

后端 未结 2 1031
不知归路
不知归路 2020-12-01 11:18

This is something of a bloated question, so I apologize ahead of time. I\'m curious about how gprof works on a low technical level. I understand it\'s done by timers, but th

2条回答
  •  独厮守ぢ
    2020-12-01 11:56

    Well, this gives a good explanation. Also this explains statistical profiling

    Essentially gprof will change the executable of your program (this is called instrumenting the code) to store some book-keeping information, e.g. how many times a function is called.

    The statistical profiling bit comes from snooping the program counter regularly to get a sample of what your code is doing.

    Gprof does both. It instruments the code and collects samples from looking at the program counter.

提交回复
热议问题