I just used gprof to analyze my program. I wanted to see what functions were consuming the most CPU time. However, now I would like to analyze my program in a different way. I want to see what LINES of the code that consume the most CPU time. At first, I read that gprof could do that, but I couldn't find the right option for it.
Now, I found gcov. However, the third-party program I am trying to execute has no "./configure" so I could not apply the "./configure --enable-gcov".
My question is simple. Does anyone know how to get execution time for each line of code for my program?
(I prefer suggestions with gprof, because I found its output to be very easy to read and understand.)
oprofile is probably, as suggested by Anthony Blake, the best answer.
However, a trick to force a compiler, or a compiler flag (such as
-pgforgprofprofiling), when compiling anautoconf-ed software, could beor
This is also useful for some newer modes of compilation. For instance, gcc 4.6 provides link time optimization with the
-fltoflag passed at compilation and at linking; to enable it, I often doFor a program not autoconf-ed but still built with a reasonable
Makefileyou might edit thatMakefileor tryor
It usually (but not always) work.