Using Webgrind for PHP Application

How to install, configure and evaluate PHP performance with Webgrind


~ # cd /opt
. # git clone https://github.com/jokkedk/webgrind.git
. # cd /var/www/site/webroot
. # ln -s /opt/webgrind ./webgrind

You will need to have a recent version of PHP, mod_uniq and media-gfx/graphviz, if you want to see graphs.

Now Webgrind will be visible from that webroot. Adjust the path for /var/www/site/webroot to include your web-directory.

Configure PHP#

I like to put these values in the Apache VirtualHost configuration

    # xdebug
    php_flag xdebug.profiler_enable off
    php_flag xdebug.profiler_enable_trigger on
    php_flag xdebug.profiler_append off
    php_value xdebug.profiler_output_dir /tmp/phprof
    php_value xdebug.profiler_output_name %U.xdebug
    php_value xdebug.trace_output_dir /tmp/phprof
    php_value xdebug.trace_output_name %U.xtrace

Also, you must create this output directory, and change owner to the web server user.

~ # mkdir -p /tmp/phprof
~ # chown -R apache:apache /tmp/phprof

Profiling Scripts#

To profile scripts you must set a POST, GET or cookie value: XDEBUG_PROFILE=true. See the xdebug reference for more information.

curl --cookie XDEBUG_PROFILE=true http://site.to/test.php

Loading Comments from Disqus...