-p, -pg, -qprofile

Category

Optimization and tuning

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 a program compiled with -p, and it ends normally, it writes the recorded information to a mon.out file; a program compiled with -pg writes a gmon.out file. You can then use the prof or gprof command to generate a runtime profile.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-+- -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.

If the -qtbtable option is not set, the profiling options will generate full traceback tables.

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