Virtual Machine Profiling
Last updated at 2:33 pm UTC on 16 January 2006
From: Scott A Crosby <firstname.lastname@example.org>
Subject: Re: More Profiling
Date: Wed, 26 Sep 2001 06:20:58 -0400 (EDT)
BTW, for those who are interested in how I did it. Install Linux.
For full profiling, including basic block level, compile with options '-g -pg -a'. (basic blocks are the parts between branches, so basic-block level profiling will tell you each time any conditional is taken. Each time a case: in a switch is taken, etc) Basic block profiling slows the virtual machine down by about 15%.
If you just want line-level and function level, compile with flags '-g -pg'.
Run it a while, then exit normally. You get two files: gmon.out and bb.out
If you're doing basic-block level profiling, you need to convert bb.out so that gprof can use it:
# perl /usr/share/doc/binutils/gprof/bbconv.pl < bb.out >bbFOO.out
# gprof -l -A -x squeak gmon.out bbFOO.out | less
will annotate your source code with number of invocations of any loop,
And, you can always do:
# gprof -l squeak gmon.out | less
will give you line level profiling (the second table given above)
# gprof squak gmon.out | less
will give you function-level profiling.
For more info, read the 'gcc' and 'gprof' texinfo documentation. Do NOT read the man pages. The manpages are very out of date.