
gprof(1) | gprof(1) |
Produce a pro®le ®le gmon.sum that represents the sum of the pro®le information in | |
| all speci®ed pro®le ®les. This summary pro®le ®le can be given to subsequent execu- |
| tions of gprof (probably also with a |
| several runs of an a.out ®le. |
Display routines that have zero usage (as indicated by call counts and accumulated | |
| time). |
The name of the ®le created by a pro®led 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 pre®x removed, and pid is the program's process ID. If GPROFDIR is set to a null string, no pro®ling output is produced.
EXAMPLES
To pro®le libc.sl:
$ cat > test.c main()
{
printf("hello world\n");
}
$ | cc test.c |
|
$ | 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.pro®le
$ ll libc.2.profile
lang | 606464 May 19 10:24 libc.2.pro®le |
$ 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 pro®led have the time of their pro®led 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 pro®led, appear to be spontaneous (although for more obscure reasons). Any pro®led children of signal catchers should have their times propagated properly unless the signal catcher was invoked during the execution of the pro®ling routine, in which case all is lost.
The pro®led program must call exit() (see exit(2)) or return normally, for the pro®ling information to be saved in the gmon.out ®le.
The following limitations exist for gprof shared library pro®ling:
∙Local, static, and hidden functions are not pro®led.
∙Shared libraries built with
∙Any function calls made from library initializers are 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 ®nd this value by running the ldd command on the executable.
− 2 − | Section 1−337 |
g