Webgrind: Cross-platform Xdebug Profiling Web Frontend
Posted by Hodge on Apr 21, 2009 in Programming, Web Development • No comments •
I’m using Xdebug as my primary PHP debugger. I have it integrated into my Eclipse PDT IDE, and have also been using its profiling capabilities. Until recently, I’ve been using KCachegrind – which has a wonderfully diverse feature set – as my primary profile data visualisation tool. However, as a Gnome user, KCachegrind requires a lot of KDE libraries to be installed in order to run. KCachegrind can be installed easily on Debian based systems by running:
sudo apt-get install kcachegrind
Anyone who has installed KCachegrind on a Gnome system before, or who has just run the above command, can see that it takes approximately 250Mb (after installation – about 80Mb worth of archives to download) of additional libraries and packages in order to install. I still have it installed, and use it for more detailed analysis of profile data, but I recently stumbled across a fantastic alternative called Webgrind.
Installing Webgrind
Webgrind implements a subset of the KCachegrind features, and is great for a quick preview, or simple analysis of profile data. It’s written in PHP5, and as such leaves a very small footprint, and can be installed on any platform. To install, download the latest package (1.0 at the time of writing) – as usual I downloaded to my cluttered Desktop, which by now is brimming with things I’ve forgotten about, and whose purpose I no longer have any idea… Once downloaded, the package needs unpacking, and moving to the root web directory (/var/www in my case)
cd ~/Desktop
unzip webgrind-release-1.0.zip
sudo mv webgrind /var/www
Once installed, Webgrind can be accessed by pointing your web browser to http://localhost/webgrind
Profiling
In order to profile an application, the Xdebug profiler needs switching on. This can be done by editing either the php.ini file, or in my case, a separate ini file specifically for Xdebug. Either way, the following line needs adding, so open up the ini file in a text editor, and add:
xdebug.profiler_enable = 1
Save the file and restart Apache:
sudo /etc/init.d/apache2 restart
Your PHP web application will now be profiled by Xdebug. By default, profile data will be saved in /tmp/cachegrind.out.%p (where %p is the pid). This can be changed by editing php.ini and adding the following directives:
xdebug.profiler_output_dir = /desired/output/directory/path
xdebug.profiler_output_name = desired.name.specifier
(See http://www.xdebug.org/docs/all_settings#trace_output_name for possible specifiers). To switch profiling off, simply edit the php.ini file, set xdebug.profiler_enable to 0 and restart Apache.
Viewing Profile Data
Once profile data is available, Webgrind will automatically detect the latest profile, and give the option to display it. Point your web browser to http://localhost/webgrind. At the top are three pull down menus – the centre menu allowing us to select which profile data file to view. By default, it will automatically select the latest file, but others can be manually selected based not only on Xdebug’s default filename, but also by the actual PHP file profiled. Clicking the Update button will begin the analysis process (which may take some time depending on the size and complexity of the profile data) resulting in data being displayed in tabular format, which allows for drill down and sorting:

KCachegrind can be used for more detailed analysis, but for a quick view of potential bottlenecks in code, and considering its size, Webgrind is a fantastic starting point, which for me, picks out the most relevant data I need to analyse, which is sufficient 90% of the time.
Something not quite right? Inaccuracies or invalid code? Didn’t work for you? Don’t like me using Ss instead of Zs? Add a comment below! All comments are welcome. Except spam, because spam is a bit crap.
|
|
Seis De Mayo $4.29 It wasn’t long after the recording of this, Trey Anastasio’s third–and most warmly idiosyncratic–solo album, that the Phish frontman/guitarist announced that his improvisation-fueled, cult-fave band would record no more. Longtime Phish-heads (or admirers of Anastasio’s previous free-form jazz excursions with Les Claypool and Stewart Copeland and more conventional solo work) may find this ambitio… |
|
|
Sapphire Video Card 100314-3l Hd 6870 1gb Ddr5 256bit Pci Express D-Dvi/Hdmi/Display Port Retail $222.69 PCI Express based PC is required with one X16 lane graphics slot available on the motherboard.4X75 Watt 6-pin PCI Express power connector is required for CrossFireX system.2X75 Watt 6-pin PCI Express power connector is required.1024MBMinimum of system memory.Installation software requires CD-ROM drive.DVD playback requires DVD drive.Blu-ray/HD DVD playback requires Blu-ray/HD DVD drive.Blu-ray/HD … |
|
|
VideoSecu Portable Adjustable DVD CD Player Mount for Car Headrest- Black Color MDC20 M25 $9.49 The VideoSecu DVD mount is designed for mounting portable DVD player to the car headrest. Mount the DVD player to the back of the front seat, for the passengers in the back seat to view. Adjustable arms fits different size DVD player up to 10 inch wide, and is compatible with most cars. The adjustable tilt function provides comfortable viewing angle and reduce screen glare. This mount bracket is… |
|
|
Pro Series Car Travel Power Inverter / Charger with USB port for Laptops, Portable DVD Players, SmartPhones, Tablets and More $29.99 Car Power Inverter for laptops, DVD Players, Tablets, Portable T.V’s, MP3, Smartphones and more!Hassle free Power Powers your device through a standard car DC Adapter. Simply plug the Mobile Powerflex into your cigarette lighter and it provides a wall socket to plug your devices adapter directly into.Compact and ConvenientWeighs only 5 oz and fits in your pocket! Sleek design doesn’t add bulk and… |
|
|
Brunton 26 Watt Foldable Solar Array $539.99 The next generation of Solaris foldable solar technology is here with the Brunton Solaris 26 Watt Foldable Solar Array . CIGS (Copper Indium Gallium diSelenide) is the most efficient thin film solar technology available. Power your laptop and other large electronics while camping, backpacking, climbing and more! By maximizing performance while optimizing portability, it makes the Solaris 26 a gre… |
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.




