-p, -pg, -qprofile

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

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.

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.
  • The -p and -pg options that GCC provides. For details, see the GCC online documentation at http://gcc.gnu.org/onlinedocs/.


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us