views:

202

answers:

1

I do not understand the documentation for gprof regarding how to compile your program for profiling with gprof. In g++, is it required to compile with the -g option (debugging information) in a addition to the -pg option or not. In each case I get different results, and I would like to see where the bottlenecks in my application are in release mode, not in debug mode, where many optimizations are left out by the compiler (e.g. inlining)

+1  A: 

The documentation shows that you can do either, noting that you need -g for line by line profiling. So if you want to profile under release conditions, and can accept not doing line-by-line, you should be able to compile without -g.

Matthew Flaschen
I am only interested in function calls, not line by line profiling. Without the -g option, many functions that are being called do not show up. I do not think this is due to inlining, because many of those methods are big ones (50+ lines of code).
myahya
@myahya, I think it very well may be inlining. By default, GCC may inline functions up to 400 internal GCC instructions long (I know these don't map directly to lines of code); see http://bazaar.launchpad.net/~vcs-imports/gcc/trunk/annotate/99780/gcc/params.def#L58. Also, what compilation flags are you using?
Matthew Flaschen