Difference between revisions of "Profiling"
Revision as of 09:00, 3 July 2006
How to Profile
Here is a description of how to profile under Linux from Bryce Harrington:
Here is how I've done profiling for Inkscape in the past. I have no idea if this will work on Win32 though since profiling requires kernel calls, so you may have to do some adapting.
There are essentially three major steps:
A) Compile the application with profiling support
B) Run the application in a "certain way"
C) Run gprof to generate analysis reports
For Step A what you need to do is add the -pg option to the compiler. You can do this via the CXXFLAGS variable at configure time. For example in Bash:
$ CXXFLAGS='-pg' ./configure $ make
Step B is where some creativity is needed. You'll probably want to do several profiling runs to get the hang of it. Essentially, you want to exercise the part of the program you're most interested in measuring. For instance, if you're measuring the speed of rendering stars, you may want to create a document full of zillions of stars, and start Inkscape with that file, then immediately close when it finishes rendering.
As part of Step B, a special output file is generated (called gmon.out by default). In Step C, you run gprof on inkscape executable and this file to generate different sorts of reports, such as the flat profile and call graph. For example here's how to get the plain default report:
$ gprof inkscape gmon.out > report
Read the report file for a table of functions sorted by how much time each function worked during this run of Inkscape. See the gprof manpage for all the analysis report options.