View xdebug cachegrind files on Mac OS

Xdebug is key when it comes to optimizing PHP code. Today, I heard my colleague boot up a Windows machine just to run an application that could interpret a cachegrind file generated by our development server… surely there must be a Mac equivalent! The following instructions will let you interpret cachegrind files locally on your Mac. You’ll still have to download the cachegrind file locally from your server.

Note that I’m doing this on Mavericks 10.9.2. I will not explain how to install Xdebug on your server or how to create the cachegrind file.

First, install Homebrew on your machine. From your terminal, run :
ruby -e “$(curl -fsSL”

Then, run :
brew install qcachegrind
brew install graphviz

Then, download your cachegrind file locally to your machine and, to view the output, simply execute

[shell]qcachegrind cachegrind.out.26620[/shell]

You will get something that looks like this :

Screenshot of what qcachegrind produces.
Screenshot of what qcachegrind produces.

Optimize away!

PS: For live debugging via xdebug, I use

4 thoughts on “View xdebug cachegrind files on Mac OS”

  1. Pingback: crash test dev

Leave a Reply

Your email address will not be published. Required fields are marked *