tags:

views:

219

answers:

3

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

gprof -l -F function_name ...

does not seem to work.

Thanks, Bi.

+1  A: 

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.

Karl Voigtland
I am using icc (icpc) i.e intel compiler on Linux and cannot get gcov working on it! I shall check out symspec. Thanks.
Bi
+1  A: 

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.

fco.javier.sanz
A: 

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.

Mike Dunlavey