Table of Contents
First, one wants to generate performance data by measuring aspects of the runtime characteristics of an application, using a profiling tool. KCachegrind itself does not include any profiling tool, but is good in being used together with Callgrind, and by using a converter, also can be used to visualize data produced with OProfile. Although the scope of this manual is not to document profiling with these tools, the next section provides short quickstart tutorials to get you started.
Callgrind is a part of Valgrind. Note that it previously was called Calltree, but that name was misleading.
The most common use is to prefix the command line to start your application with
valgrind
, as in:
--tool=callgrind
valgrind
--tool=callgrind
myprogram
myargs
At program termination, a file
callgrind.out.
will be
generated, which can be loaded into KCachegrind.
pid
More advanced use is to dump out profile data whenever a given function of your
application is called. E.g. for Konqueror, to see profile data only for the
rendering of a Web page, you could decide to dump the data whenever you select
the menu item → . This corresponds to a call to
KonqMainWindow::slotReload
. Use:
valgrind
--tool=callgrind
--dump-before=KonqMainWindow::slotReload
konqueror
This will produce multiple profile data files with an additional sequential number at the end of the filename. A file without such an number at the end (only ending in the process PID) will also be produced; by loading this file into KCachegrind, all others are loaded too, and can be seen in the Parts Overview and Parts list.
OProfile is available from its home page. Follow the installation instructions on the Web site, but, before you do, check whether your distribution does not already provide it as package (like SuSE®).
System-wide profiling is only permitted to the root user, as all actions on the
system can be observed; therefore, the following has to be done as root.
First, configure the profiling process, using the GUI
oprof_start or the command-line tool
opcontrol. Standard configuration should be timer mode
(TBS, see introduction).
To start the measurement, run opcontrol
.
Then run the application you are interested in and, afterwards, do a
-s
opcontrol
. This
will write out the measurement results into files under folder -d
/var/lib/oprofile/samples/
.
To be able to visualize the data in KCachegrind, do in an empty directory:
opreport
-gdf
| op2callgrind
This will produce a lot of files, one for every program which was running on the system. Each one can be loaded into KCachegrind on its own.