line-by-line profiling

Segher Boessenkool segher@koffie.nl
Fri Nov 29 04:31:00 GMT 2002


"Neal D. Becker" wrote:
> Any way to get line-by-line timing info?  I see only how to get
> execution count from gcov, I'm really looking for profile of execution
> time.

gcc -pg -g   and   gprof -l   works fine for me (well, using C, not C++).
Beware of large statistical differences when using the default profiling
timer though, as it is quite coarse for line-by-line profiling use, at least
on Linux.  And you get to see the "profiling lag" (e.g., the line _after_ a
line with, say, an integer division gets a big time percentage; not the line
itself).  Using a good hardware performance counter mechanism is much preferable.
Oh, and  gprof -l  is utterly slow.


Segher





More information about the Gcc mailing list