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)
Asked
Active
Viewed 1.3k times
9

myahya
- 3,079
- 7
- 38
- 51
-
http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343 – Mike Dunlavey May 04 '10 at 11:31
-
1`-g` does not mean that optimizations are turned off. `-O` controls opimization. You can compile with both `-g` and `-O2` for example. – Paul Coccoli Oct 08 '14 at 00:59
1 Answers
6
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
- 278,309
- 50
- 514
- 539
-
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 May 03 '10 at 20:16
-
1@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 May 03 '10 at 21:58