10.4 Support for gprof, the gnu proler

You can compile your programs with proling support. for this, you just have to use the compiler switch -pg. The compiler wil insert the necessary stu for proling.

When you have done this, you can run your program as you normally would run it.

yourexe

Where yourexe is the name of your executable.

When your program nishes a le called gmon.out is generated. Then you can start the proler to see the output. You can better redirect the output to a le, becuase it could be quite a lot:

gprof yourexe > profile.log

Hint: you can use the {at option to reduce the amount of output of gprof. It will then only output the information about the timings

For more information on the gnu proler gprof, see its manual.