Table of Contents Previous Slide Next Slide

Software Development in the UNIX Environment
More on Profiling Your Code

Other Profiling Tools (platform dependent)

gprof - gives a call graph profile of which route call other routines and how often plus duplicates prof capabilities

An example: ( best not to optimize code )

Using gcc

gcc -o file -pg file.c (compile and link with -pg option)
file ( run program and produces 'gmon.out')
gprof file > file.gprof

On solaris

cc -o file -xpg file.c (compile and link with -pg option)
file ( run program and produces 'gmon.out')
gprof file > file.gprof

On AIX

cc -o file -pg file.c (compile and link with -pg option)
file ( run program and produces 'gmon.out')
gprof file > file.gprof

Example of gprof output


index  %time    self descendents  called+self    name          index
                                  called/total       children

                0.00       30.89       1/1           .__start [2]
[1]     46.3    0.00       30.89       1         .main [1]
                3.74       27.14       7/7           .doAnisotropicScatter [3]
                0.00        0.01       1/1           .parseFile [24]
                0.00        0.00      22/39          .fprintf [59]
                0.00        0.00       4/53          .printf [55]
                0.00        0.00       3/18          .time [78]
                0.00        0.00       2/2           .ctime [97]
                0.00        0.00       2/18          .localtime [74]
                0.00        0.00       1/1           .srand [111]
                0.00        0.00       1/1           .difftime [102]
                0.00        0.00       1/17          .fopen [86]
                0.00        0.00       1/17          .fclose [83]

-----------------------------------------------

                3.74       27.14       7/7           .main [1]
[3]     46.2    3.74       27.14       7         .doAnisotropicScatter [3]
                9.90        9.20 27621579/27621579     .scatter [4]
                3.35        4.61 27691579/27691579     .path [9]
                0.02        0.03   70000/70000       .initPhoton [16]
                0.03        0.00   70000/70000       .score [18]
                0.00        0.00      21/53          .printf [55]
                0.00        0.00       7/7           .printTissueParams [93]
                0.00        0.00       7/7           .clearIntensityArray [91]
                0.00        0.00       7/7           .dump1 [92]

-----------------------------------------------


Other profiling tools:

tcov - Sun tool that tells the number of times each source code line was called. (-xa compile flag)

Speedshop (ssrun)- SGI Irix program that can identify CPU, memory and I/O bottlenecks