Install Webgrind to profile Drupal and other PHP applications on OS X

Screenshot of Webgrind

A coworker recently clued me in on Webgrind, a platform independent, browser-based PHP profiling application. I was impressed with it, and thought I'd contribute to the installation and usage instructions that are floating around the web with my specific setup.

Assumes you're using MAMP on OS X, but you can probably adapt.

  1. Install XDebug: I like the instructions at since they come with info on how to use XDebug for, well, debugging. (Note my comment on that post).
  2. Install Webgrind: Download, unpack and copy the webgrind directory to your web root.
  3. Add the following lines to the end of your php.ini (/Applications/MAMP/conf/php5/php.ini if you use PHP 5 in MAMP):
    xdebug.profiler_enable = 1
    xdebug.profiler_output_dir = /path/to/htdocs/webgrind/tmp
    xdebug.profiler_output_name = cachegrind.out.%t.%p

    Be sure to edit the path to match the location of your web root. Additionally, create the tmp directory under your webgrind directory.
  4. Edit Webgrind's config.php to use your /path/to/htdocs/webgrind/tmp:
    static $storageDir = '/path/to/htdocs/webgrind/tmp';
    static $profilerDir = '/path/to/htdocs/webgrind/tmp';
  5. Restart Apache for your php.ini settings to take effect.

(For another take on installation, see

Once it's up and running, make some localhost requests. Then visit http://localhost/webgrind (or wherever you've installed Webgrind).

Select the profile file you'd like to use.
Webgrind's select file UI

If you're using a CMS such as Drupal, I recommend setting the "Show" percentage to 100% (the default is 90%), as it's likely the code you're wanting to profile is your own, which tends to drop off into the last 10% when you're dealing with CMS profiling.

When the profiler finishes processing the profile data you selected, you'll get a report similar to that depicted below.
Detail view of Webgrind report

Worth noting is the blue, lavender (here it's just a sliver), green and orange bar. These colors represent the distribution of built-in PHP functions (blue), include/require functions (lavender), class methods (green) and procedural functions (orange). Down the left side of the list of functions profiled, the color of the dots maps to these categories.

Now, click the arrow next to a function and you'll get a listing of function invocations, where each call occurred and their costs. This listing corresponds to the invocation count column.

Note also the Total Self Cost and Total Inclusive Cost columns. The former indicates the processing time for only the code in the function, while the latter also includes processing for calls to other functions made from that code.

The paragraph icons service as a nice added feature. Clicking them opens a new tab or browser window with the contents of the file that function is defined in.

When you're done using Webgrind, either update your php.ini to set

xdebug.profiler_enable = 0

Or if you'd rather, leave the profiler enabled. It'll only create profile files for localhost requests. These can eat up drive space and slow Webgrind though, so I prefer to turn it off when not I'm not using Webgrind.

In summary, there are other, heavier-weight, and more fully featured web profiling applications out there (such as kcachegrind) but for ease of use, platform independence, and a succinct but effective feature set, Webgrind is a great addition to any PHP dev's toolbox.


aadi wrote 36 weeks 2 days ago

It is actually really nice

It is actually really nice and kind when I stumble across ourselves that bind us together.
Graphics automation

Asshole wrote 31 weeks 3 days ago

Now i can finish this

Now i can finish this download/installation. :3
how to get more plays on soundcloud

ashtonwalker wrote 16 weeks 2 days ago

The former indicates the

The former indicates the processing time for only the code in the function, while the latter also includes processing for calls to other functions made from that code.

how to buy soundcloud followers

Mark wrote 16 weeks 1 day ago

The top essay must be regards

The top essay must be regards the british essays it’s the become good. And its concerns the good of the people using the find of the and good of the paper essays and its conducts.

Raushan Kumar wrote 11 weeks 1 day ago

Best Movers and Packers India

Moving actions such as overall look, operating and shifting are the inner actions quickly done only by the well-experienced shifting assistance providers.

Sitara wrote 8 weeks 3 days ago

Easy Ways to Take pleasure in Relocation


Relocation is known as as one of the very most complicated works. There are numerous tasks responsible for that that makes it more complex. Just like packaging of the things, assembling it in shifting pickup truck, unpacking and organizing it at the new home. Such all the things mutually render relocation one of the vital stressful jobs to do. Though since we comprehend that each and every issue comes along with an answer indeed and same exact with relocation as well. There are small number of fundamental and important things which when ever adopted can make relocation probably the most pleasant jobs. These things will take your relocation to the upcoming level of simplification.

The more organized you will be the much more outlined your relocation shall be. That is why for an effective relocation it is always regarded that you move organized. In case you undertake it by your own or appoint someone else for the the same you ought to arrange it ahead of time. Performing it by individual a very good idea truly but you need to find out specific stuffing of unique products just like vulnerable, electronics and so forth in order that it might be transferred on correct. The 3rd most important point is to find help/ you could have the co-operation of friends and family besides other every member of the family and that you can also they can take pleasure in while stuffing and shifting. Include good plannings of drinks and amusement in the middle so it can no longer be a hectic arrangement for you. These all things and techniques will in reality help make your current relocation a truly easy also pleasure loving job.
packers and movers pune

packers and movers aundh

packers and movers hinjewadi

rohan singh wrote 5 weeks 5 days ago

How may be the purchaser

How may be the purchaser impression on the firm? You possibly can understand that through the testimonials released inside web site.

To learn more you may stop at:

rohan singh wrote 5 weeks 5 days ago

Within more to this there are

Within more to this there are numerous transferring corporations that offers the ability involving automobile travel combined with the overall family inside identical products. That way one could method house and auto while doing so inside the completely new spot. However customers should always remember them to use any reputable one particular for move in order that their item along with their vehicle will continue secure underneath their own person and you'll be given your own objects within the similar position inside that you've managed the idea up to them.

To learn more you may stop at:

rohan singh wrote 5 weeks 5 days ago

Will you be transferring as

Will you be transferring as well as switching via Delhi to help some other place? Do you have a great deal of things, goods and also home consequences which usually you need to transfer on your new destination? Do you think your current household separation by Delhi would have been a very tiring and hectic celebration you have ever had? Ya think you might confront a lot of issues within providing off your current possessions? Are you currently tremendously interested in ideal packaging in addition to carting connected with items on your move via Delhi to some new metropolis?

To learn more you may stop at:

Add your comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Find Me Around

User login