gprof and dot – some hints using gprof, gprof2dot and dot

Recently done a performance tuning using gprof, gprof2dot and dot. While there are already a lot of webs talking about them respectively or generally. This post is trying to provide some hints from my real experience, as well as some usefully links for reference. May it help.

(provided by Ethan.Yu@alcatel-lucent.com)

Hint 1: ‘-pg’ is needed both in compiling and linking: If the binary is generated from source within one cmd, please no worry about this. However, as long as ‘Make’ is used. Make sure you have ‘-pg’ in the 2 stages. Otherwise, call graph data would be lost in the gprof report.

Hint 2: gprof: gmon.out file is missing call-graph data: There are 2 possibilities worth checking. A, there is no call graph indeed as our code is simple; B, ‘-pg’ is only included during the linking stage but not compiling.

Hint 3: which kind of gprof report is in favor of gprof2dot: ‘gprof BIN gmon.out > report.txt’ is fairly good enough.

Hint 4: commands summary:

gcc -g -pg -o BIN SRC.c
———————————
gcc -g -pg -c SRC.c
gcc -pg -o BIN SRC.o
———————————
gprof BIN gmon.out > report.txt
———————————
gprof2dot report.txt > report.dot
———————————
dot -Tpng -oreport.png report.dot

Hint 5: useful links:

gprof and gprof2dot brief intro (Chinese version)

‘-pg’ option for gprof

gprof2dot

dot

About daveti

Interested in kernel hacking, compilers, machine learning and guitars.
This entry was posted in IDE_Make, Programming, Stuff about Compiler and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s