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
apt-get install kcachegrind
Note that there are versions for windows and mac on the website.
Load the profile
Post new comment
- software design
10 Latest Items
blog Traveling It just occured to me that I havn't updated this website with a blog post saying that I am now on my big bike tour. I left at the end of February with my Dad and we rode down to Clermont Ferrand in sometimes very cold and wet conditions, to meet u...
blog The Auto Route Bundle I have almost finished my first `symfony-cmf` bundle, the `RoutingAutoBundle`.
blog Race Day Race Day
blog FInding lost commits How many times have you done some work on some branch, which was not the right branch, only to go back to the branch you __thought__ you were working on, only to find out that your precious commit has dissapeared, where is it?
blog Moving email to the console !Disclaimer -- this is a work in progress and if anything is a personal reference...
blog 3 days on the Loire "Where shall I go?"
blog Cycling in England and Wales and France Eurostar Bon Voyage 14 euros to St. Pancras station and train then metro to Wimbledon Park rendezvous avec mon frere and coffee in a wimbledon high-street café. Bikes locked and not stolen. Books bought. More coffee. Dinner etc. Later left in morning e...
blog Paris to Amsterdam: Paris to Brussels I left Paris at 6:30 in the morning reasoning that I would be able to cover the distance to Brussels in 12 hours. I felt the chill in my eyes 2 miles from my appartement and I realised I had forgotten to bring my new sunglasses. I returned to the appar...
blog From blueprint to bootstrap I have just finished updating my Symfony2 <a href="http://github.com/dantleech/TrainerBundle">Trainer</a> application to use <A href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>.
blog DOMNodeList doesn't implement Traversable interface in PHPv5.3.2-1ubuntu4.14 So I have just spent about 4 hours scratching my head, then cursing at my computer as for some inexplicable reason TWIG would not iterate over my DONNodeList.