Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
g
gprof(1) gprof(1)
-s Produce a profile file gmon.sum that represents the sum of the profile information in
all specified profile files. This summary profile file can be given to subsequent execu-
tions of gprof (probably also with a -s option) to accumulate profile data across
several runs of an a.out file.
-z Display routines that have zero usage (as indicated by call counts and accumulated
time).
The name of the file created by a profiled program is controlled by the environment variable GPROFDIR.
If GPROFDIR is not set, gmon.out is produced in the current directory when the program terminates. If
GPROFDIR=string, string/pid.progname is produced, where progname consists of argv[0] with any
path prefix removed, and pid is the program’s process ID. If GPROFDIR is set to a null string, no profiling
output is produced.
EXAMPLES
To profile libc.sl:
$ cat > test.c
main()
{
printf("hello world\n");
}
$ cc test.c -lc
$ ldd a.out
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
$ export LD_PROFILE=/usr/lib/libc.2
$ ./a.out
hello world
$ unset LD_PROFILE
$ ls libc.2.profile
libc.2.profile
$ ll libc.2.profile
-rw-rw-r-- 1 user1 lang 606464May 19 10:24 libc.2.profile
$ gprof /usr/lib/libc.2 libc.2.profile
WARNINGS
Beware of quantization errors. The granularity of the sampling is shown, but remains statistical at best. It
is assumed that the time for each execution of a function can be expressed by the total time for the func-
tion, divided by the number of times the function is called. Thus the time propagated along the call graph
arcs to parents of that function is directly proportional to the number of times that arc is traversed.
Parents that are not profiled have the time of their profiled children propagated to them, but they appear to
be spontaneously invoked in the call graph listing, and do not have their time propagated further. Simi-
larly, signal catchers, even though profiled, appear to be spontaneous (although for more obscure reasons).
Any profiled children of signal catchers should have their times propagated properly unless the signal
catcher was invoked during the execution of the profiling routine, in which case all is lost.
The profiled program must call exit() (see exit(2)) or return normally, for the profiling information to be
saved in the gmon.out file.
The following limitations exist for gprof shared library profiling:
Local, static, and hidden functions are not profiled.
Shared libraries built with -B symbolic are not profiled.
Any function calls made from library initializersare not collected.
Set LD_PROFILE to the exact string with which you call shl_load. If the library is implicitly loaded,
LD_PROFILE must match the path encoded in the a.out. You can find this value by running the
ldd
command on the executable.
HP-UX Release 11i: December 2000 2 Section 1337
___
___