The prof command
The prof command displays a profile of CPU usage for each external symbol, or routine, of a specified program.
In detail, it displays the following:
- The percentage of execution time spent between the address of that symbol and the address of the next
- The number of times that function was called
- The average number of milliseconds per call
The prof command interprets the profile data collected by the monitor() subroutine for the object file (a.out by default), reads the symbol table in the object file, and correlates it with the profile file (mon.out by default) generated by the monitor() subroutine. A usage report is sent to the terminal, or can be redirected to a file.
By default, the displayed report is sorted by decreasing percentage of CPU time. This is the same as when specifying the -t option.
The -c option sorts by decreasing number of calls and the -n option sorts alphabetically by symbol name.
If the -s option is used, a summary file mon.sum is produced. This is useful when more than one profile file is specified with the -m option (the -m option specifies files containing monitor data).
The -z option includes all symbols, even if there are zero calls and time associated.
Other options are available and explained in the prof command in the Files Reference.
# cc -o cwhet -p -lm cwhet.c
# cwhet > cwhet.out
# prof
Name %Time Seconds Cumsecs #Calls msec/call
.main 32.6 17.63 17.63 1 17630.
.__mcount 28.2 15.25 32.88
.mod8 16.3 8.82 41.70 8990000 0.0010
.mod9 9.9 5.38 47.08 6160000 0.0009
.cos 2.9 1.57 48.65 1920000 0.0008
.exp 2.4 1.32 49.97 930000 0.0014
.log 2.4 1.31 51.28 930000 0.0014
.mod3 1.9 1.01 52.29 140000 0.0072
.sin 1.2 0.63 52.92 640000 0.0010
.sqrt 1.1 0.59 53.51
.atan 1.1 0.57 54.08 640000 0.0009
.pout 0.0 0.00 54.08 10 0.0
.exit 0.0 0.00 54.08 1 0.
.free 0.0 0.00 54.08 2 0.
.free_y 0.0 0.00 54.08 2 0.