-p, -pg, -qprofile
Category
Pragma equivalent
None.
Purpose
Prepares the object files produced by the compiler for profiling.
When you compile with a profiling option, the compiler produces monitoring code that counts the number of times each routine is called. The compiler replaces the startup routine of each subprogram with one that calls the monitor subroutine at the start. When you execute the compiled program and it ends normally, it writes the recorded information to a gmon.out file. You can then use the gprof command to generate a runtime profile.
Syntax
>>-+- -p---------------------+--------------------------------->< +- -pg--------------------+ '- -q--profile--=--+-p--+-' '-pg-'
Defaults
Not applicable.
Usage
When you are compiling and linking in separate steps, you must specify the profiling option in both steps.
Predefined macros
None.
Examples
To compile myprogram.c to
include profiling data, enter:
xlc myprogram.c -p
Remember
to compile and link with one of the profiling options. For
example:
xlc myprogram.c -p -c
xlc myprogram.o -p -o program
Related information
- See your operating system documentation for more information on the gprof command.
- For details about the GCC options -p and -pg, see the GCC online documentation at http://gcc.gnu.org/onlinedocs/.