Profile single function in gprof

Is it possible to use gprof to line-profile a single function in C++?

Something like:

gprof -l -F function_name ...

, which does not seem to work.


That can be done easily with valgrind. It is a wonderful tool if you have the chance to use it in your development environment. It even have and graphical interface kcachegrind.


Try using options with [symspec] to filter the results. gprof 2.18.0 says that -F and -f are deprecated and to use symspec instead.

Also, -l may not work with binaries compiled with newer versions of gcc. Try gcov instead.


Are you looking for a suspected performance problem? If you have a preconception of where it is, chances are it's not there. If you really want to find performance problems, first you may need to look beyond some myths perpetuated by gprof .

链接地址: http://www.djcxy.com/p/43858.html

上一篇: 时间采样问题与gprof

下一篇: 在gprof中描述单个函数