prof++ [-b format] [-tcan] [-ox] [-gl] [-h] [-m mdata ] [-s] [-z] [-V] [prog]
prof++(CP) pipes the output of prof through a filter that translates C++ mangled names to human-readable forms. This makes the output of prof more readable. C names are passed unchanged.
By default, prof scans prog to determine its file format and executes the appropriate binary. Use the option -b format to force prof to use a particular file format:
The mutually exclusive options -t, -c, -a, and -n determine the type of sorting of the output lines:
The mutually exclusive options -o and -x specify the printing of the address of each symbol monitored:
Assume that A and B are global functions and only A calls static function S. If S is located immediately after A in the source code (that is, if S is properly located), then, with the -l option, the amount of time spent in A can easily be determined, including the time spent in S. If, however, both A and B call S, then, if the -l option is used, the report will be misleading; the time spent during B's call to S will be attributed to A, making it appear as if more time had been spent in A than really had. In this case, function S cannot be properly located.
If prog is a COFF file, prof attributes the times for static functions to the preceding external text symbol if the -g option is not used. However, the call counts for the preceding function are still correct (that is, the static function call counts are not added in with the call counts of the external function).
The following options can be used in any combination:
A program creates a profile if it has been loaded with the -p option of cc(CP). This option to cc arranges for calls to monitor(S) at the beginning and end of execution. It is the call to monitor at the end of execution that causes the profile to be written. The number of calls to a function is tallied if the -p option was used when the file containing the function was compiled.
The name of the file created by a profiled program is controlled by the environment variable PROFDIR. If PROFDIR does not exist, mon.out is produced in the directory that is current when the program terminates. If PROFDIR = string, ``string/pid.progname'' is produced, where progname consists of argv with any path prefix removed, and pid is the program's process id. If PROFDIR is the null string, no profiling output is produced.
A single function can be split into subfunctions for profiling by means of the MARK macro (see prof(M)).
Only programs that call
or return from
cause a profile file to be produced,
unless a final call to monitor is explicitly coded.
The use of the -p option to cc(CP) to invoke profiling imposes a default limit of 600 functions that may have call counters established during program execution. If this limit is exceeded, other data are overwritten and the mon.out file is corrupted. For more counters you can call monitor(S) directly.
If prog is an ELF file, prog may have been built as a dynamically linked executable. Profiling may be used with dynamically linked executables, but care must be applied. Currently, dynamically linked libraries (shared objects) cannot be profiled with prof. Thus, when a profiled, dynamically linked program is executed, only the ``main'' portion of the image is sampled. This means that all time spent outside of the ``main'' object, that is, time spent in a dynamically linked library (shared object), will not be included in the profile summary; the total time reported for the program may be less than the total time used by the program.
Because the time spent in a shared object cannot be accounted for, the use of shared objects should be minimized whenever a program is profiled with prof. If possible, the program should be linked statically before being profiled. See the -dn option of cc(CP).
Consider an extreme case. A profiled program dynamically linked with the shared C library spends 100 units of time in some libc routine, say, malloc(S). Suppose that malloc( ) is called only from routine B, which consumes only 1 unit of time. Suppose further that routine A consumes 10 units of time, more than any other routine in the ``main'' (profiled) portion of the image. In this case, prof will conclude that most of the time is being spent in A and almost no time is being spent in B. From this it will be almost impossible to tell that the greatest improvement can be made by looking at routine B and not routine A. The value of the profiler in this case is severely degraded; the solution is to use archives as much as possible for profiling.
Call counts are always recorded precisely.