Profiling Programs With prof, gprof, and tcov

Hi, I have used gprof first time,its surprised me in giving call graph everything about process details.

prof - Generates a statistical profile of the CPU time used by a program and an exact count of the number of times each function is entered.

gprof - Generates a statistical profile of the CPU time used by a program, along with an exact count of the number of times each function is entered and the number of times each arc (caller-callee pair) in the program's call graph is traversed.

tcov - Generates exact counts of the number of times each statement in a program is executed.


gprof ::
Steps to get profiling information

(1). Compile your program with the appropriate compiler option.

* For C programs, use the -xpg option.

* For Fortran programs,(C++) use the -pg option.

(2). Run your program.

Profiling data is sent to a profile file called
gmon.out. This file is overwritten each time you run the program.

(3). Run gprof to generate a profile report.

The syntax of the prof command is as follows.

“ gprof –c binary > NewfileName”

(4) NewfileName will contain all profiling information in call graph display.

Prof::

1. Compile your program with the -p compiler option.

2. Run your program.

Profiling data is sent to a profile file called mon.out. This file is overwritten each time you run the program.

3. Run prof to generate a profile report.

"prof binaryfile"

And A detailed article u can find at http://docs.sun.com/source/819-3687/OtherTools.html#14206
(Thanks : development article published at sun.com)

No comments :

Post a Comment