prof(1) — Commands
Digital
NAME
prof − analyze profile data
SYNOPSIS
prof [ options ] [ prog_name [ pcsampling_data_file ... ] ]
prof −pixie [ options ]
[ prog_name [ bbaddrs_file [ bbcounts_file ... ] ] ]
DESCRIPTION
prof analyzes one or more data files generated by the compiler’s execution-profiling system and produces a listing. prof can also combine those data files or produce a feedback file that lets the optimizer take into account the program’s runtime behavior during a subsequent compilation. Profiling is a three-step process: first compile the program, then execute it, and finally run prof to analyze the data.
The compiler system provides two kinds of profiling:
1. pc-sampling interrupts the program periodically, recording the value of the program counter.
2. basic-block counting divides the program into blocks delimited by labels, jump instructions, and branch instructions. It counts the number of times each block executes. This provides more detailed (line by line) information than pc-sampling.
Using pc-sampling
To use pc-sampling, compile your program with the option −p (strictly speaking, it is sufficient to use this option only when linking the program). Then run the program, which allocates extra memory to hold the profile data, and (provided the program terminates normally or calls exit(2)) records the data in a file at the end of execution.
The environment variable PROFDIR determines the name of the pc-sampling data file and determines whether pc-sampling takes place:
•If it is not set, the pc-sampling data file is named "mon.out".
•If it is set to the empty string, no profiling occurs.
•If it is set to a non-empty string, the file is named "string/pid.progname," where "pid" is the process id of the executing program and "progname" is the program’s name, as it appears in argv[0]. The subdirectory "string" must already exist.
After running your program, use prof to analyze the pc-sampling data file.
For example:
cc -c myprog.c
cc -p -o myprog myprog.o
myprog(generates "mon.out")
prof myprog mon.out
When you use prof for pc-sampling, the program name defaults to a.out and the pc-sampling data file name defaults to mon.out; if you specify more than one pc-sampling data file, prof reports the sum of the data.
Using basic-block counting
To use basic-block counting, compile your program without the option −p. Use pixie(1) to translate your program into a profiling version and generate a file, whose name ends in ".Addrs", containing block addresses. Then run the profiling version, which (assuming the program terminates normally or calls exit(2)) will generate a file, whose name ends in ".Counts", containing block counts. Then use prof with the −pixie option to analyze the bbaddrs and bbcounts files. Notice that you must tell prof the name of your original program, not the name of the profiling version.
For example:
cc -c myprog.c
cc -o myprog myprog.o
pixie -o myprog.pixie myprog(generates "myprog.Addrs")
myprog.pixie(generates "myprog.Counts")
prof -pixie myprog myprog.Addrs myprog.Counts
When you use prof with the −pixie option, the program name defaults to a.out, the bbaddrs file name defaults to "program_name.Addrs", and the bbcounts file name defaults to "program_name.Counts". If you specify more than one bbcounts file (never specify more than one bbaddrs file), prof reports the sum of the data.
Options to prof
For each prof option, you need type only enough of the name to distinguish it from the other options (usually the first character is sufficient). If you do not specify any options, prof uses −Procedures by default.
−pixie
Selects pixie mode, as opposed to pc-sampling mode.
−Procedures
Reports time spent per procedure (using data obtained from pc-sampling or basic-block counting; the listing tells which one). For basic-block counting, this option also reports the number of invocations per procedure.
−quit n
Truncates the −Procedures listings. It can truncate after n lines (if n is an integer), after the first entry that represents less than n percent of the total (if n is followed immediately by a "%" character), or after enough entries have been printed to account for n percent of the total (if n is followed immediately by "cum%"). For example, "−quit 15" truncates each part of the listing after 15 lines of text, "−quit 15%" truncates each part after the first line that represents less than 15 percent of the whole, and "−quit 15cum%" truncates each part after the line that brought the cumulative percentage above 15 percent.
FILES
crt0.o normal startup code
mcrt0.o startup code for pc-sampling
libprof1.a library for pc-sampling
mon.out default pc-sampling data file
RELATED INFORMATION
as(1), cc(1), pixie(1).
profil(2)
FEATURES
Provided you do not use −pixie, prof processes "mon.out" files produced by earlier versions of the compiler system using the obsolete −p2 or −p3 options.
RESTRICTIONS
prof does not yet take into account interactions among floating-point instructions.