Categorized | News

Profiling your Apps with Xdebug and KCachegrind

Posted on 22 December 2004 by Demian Turner

A great way to fine tune the performance of your application is to profile it with Xdebug. When configured correctly, Xdebug will output trace files like ‘cachegrind.out.2193401842′ which you can then run through a profiling visualisation app like KCachegrind. Graphical output typically looks like this and this and will detail the number of bytes of RAM consumed by each method in your code, as well as milliseconds spent, helping you isolate bottlenecks.

There are a number of steps you’ll need to take to setup your environment before you can use these tools – if you’re running Windows, forget it, you will need a Linux flavour – the following configuration worked for Fedora Core 2.

Installing Xdebug

This is the easy part, this will give you version 2.0:

pear install xdebug

Installing KCachegrind

Goto the KCachegrind download page. Download the following libs:

  • callgrind-0.9.10
  • valgrind-2.2.0
  • kcachegrind-0.4.5

You’ll also need QT development libs:

  • qt-devel

which will not compile unless you set the following environment vars:

export QTDIR and QTHOME=/usr/lib/qt-3.3

and the KDE libs (core 2 runs the gnome desktop environment by default)

  • kdebase
  • kdebase-devel

and finally, you’ll need the graphviz package:

rpm -ivh http://www.graphviz.org/pub/graphviz/ARCHIVE/graphviz-1.12-1.i386.rpm

Have fun :-)

Bookmark and Share

1 Comments For This Post

  1. demian Says:

    a good presentation on improving performance : here

Leave a Reply

Categories

Books

Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists

Facebook