HP Pascal/HP-UX Release Notes Version A.10.08
Chapter 1 23
New and Changed Features
Profile-Based Optimization (PBO)
procedures. Also, note that when you use the +I compile-line option to
compile source files, instrumentation can be added within the code for
each subroutine in that file.
In the following example, the source file sample.p is compiled,
instrumented, and linked into sample.inst:
pc -o sample.inst -O +I sample.p
Collecting Execution Profile Statistics
To collect execution profile statistics, run your program using reasonably
representative data. The profile database file, flow.data, is created the
first time the program is run, and is updated for each subsequent
execution of the program.
The following example collects execution profile statistics by running the
sample.inst program with representative data from two input files:
sample.inst < input.file1
sample.inst < input.file2
This step, by default, logs the profile statistics in a file called
flow.data. See “Maintaining Multiple Profile Data Files” on page 24 to
change this default.
Optimizing the Program
To perform PBO, re-link the program with the +P compile-line option to
specify that you wish to use the collected profile data:
pc -o sample.opt -O +P +pgm sample.inst sample.o
The +pgm compile-line option allows you to specify an executable name
that is different from the current output file name. In the preceding
command line, the +pgm option indicates that the name of the
instrumented executable (sample.inst) differs from the name of the
optimized executable (sample.opt) that is specified with the -o option.
Source files compiled with the +I option do not need to be recompiled
after collecting the profile data. Simply relink the application with the
same options that you used in the first step to instrument the program,
but replace +I with +P. For more information about how the compiler
and linker work together to perform profile based-optimizations, refer to
HP-UX Linker and Libraries Online User Guide.