Profiling with XDebug and KCacheGrind
On using the Symfony2 profiler I was a /little/ disapointed with the lack of detailed timing information (e.g. time taken to render templates, time taken on the database, etc), but then I remembered how little value these timings has in Symfony 1.x — they basically didnt help very much with identifying why the application was slow. Fortunately there is a (much) better way to profile your application. XDebug and KCacheGrind.
XDebug provides the data and KCacheGrind provides amazing visualizations which identify percisecly where and why your applcation is slow.
Enabling XDebug Profile
To enable profiles to be written (I assume you have already installed XDebug) add the following lines to php.ini
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/tmp
; This line is optional ...
xdebug.profiler_output_name=cachegrind.out.%p
This will enable the profiler upon restarting apache and subsequently a profile will be written for each request and the files are not very small and will slow down your website, so you should only enable profiling to collect data and disable it again afterwards.
-rw-r--r-- 1 www-data www-data 22M Apr 27 23:23 cachegrind.out.10371
-rw-r--r-- 1 www-data www-data 4.4M Apr 27 23:23 cachegrind.out.10373
Profile files in /tmp
Visualizing with KCacheGrind
Install KCacheGrind
apt-get install kcachegrind
Note that there are versions for windows and mac on the website.
Load the profile
C’est puissant!
Comments
Post new comment
Tags
- DropBox
- XMPP
- android
- apache
- archos
- audacious
- awesome
- bash
- bootstrap
- bristol
- diagramming
- doctrine
- doctrine2
- git
- gloucester
- graphs
- gt540
- jack
- javascript
- manchester
- mapdroyd
- markdown
- mongodb
- paris
- php
- profiling
- projectm
- running
- scripting
- sed
- software design
- ssh
- symfony
- symfony2
- thonon-les-bains
- trainer
- travel
- twig
- ubnutu
- vim
- weymouth
- workflow
- xdebug
- xml
- ylly
- yprox
10 Latest Items
-
08
Maytrainer [Velo] paris - compiègne 153.00km / 05:48:32 / 00:02:16mpkm Fois.
-
06
Maytrainer [Velo] Vincennes Hippodrome 1hr 34.34km / 01:00:00 / 00:01:44mpkm Solo effort. Did interfals (sprinting from zebra crossing to hairpin turn).
-
05
Maytrainer [Run] Diderot > Pnt. Alx III > Rue de Charonne 13.96km / 01:08:40 / 00:04:55mpkm Good to run in the rain. Lots of traffic.
-
04
Maytrainer [Velo] Vincennes Hippodrome 1hr 32.20km / 01:00:00 / 00:01:51mpkm Rode apace a peloton, but tried not to get in the draft. Sprinted for a few minutes on every lap.
-
03
Maytrainer [Run] Dumas > P. Auguste > Belleville > Prc. de Villette > Pt. de Lilas > Pt. Vincennces 14.48km / 01:07:00 / 00:04:37mpkm Kept up a reasonably good pace. No problems from calf muscle as was the case yesterday.
-
02
Maytrainer [Run] Dumas > Diderot > Trocadero > Basitlle 14.48km / 01:10:00 / 00:04:49mpkm Experienced pain in the back of my calf and stopped a few times towards the end.
-
01
Maytrainer [Velo] Dumas > Rambouillet 123.31km / 05:06:00 / 00:02:28mpkm Paris Rambouillet. Sunny day. Ate a bakery pizza, tarte au pomme and drank a cola then lay down on a bench in the châte...
-
29
Aprtrainer [Run] 14 - 15 miles 23.34km / 01:50:00 / 00:04:42mpkm Run down the Rue Charonne, down Boulevard Henri IV, round le Ile St-Louis, along the Seine, crossing the Pont d'lén...
-
28
Aprtrainer [Velo] Vincennes Hippodrome 1hr 34.12km / 01:00:00 / 00:01:45mpkm Actually 45 minutes. Rain stopped play. Also boredom. "Sprinted" up the second half of the upside at each circ...
-
27
Aprtrainer [Run] 54 minutes 11.50km / 00:54:00 / 00:04:41mpkm Ran down and around.

