Graphical Plot of Xdebug Cachegrind

Graphical Plot of Xdebug Cachegrind - Update for How to Create Graphical View of Xdebug's Cachegrind Output.

This a command line approach of profiling a single php script using Xdebug. Running Xdebug profiler from CLI is simply by executing your php script along with xdebug directives using `-d` option, this will then create a cachegrind file which we're going to convert into a visual plot using xdebugtoolkit and Graphviz.


Requirements

Xdebug

Xdebugtoolkit

Graphviz


Procedures

Create cachegrind.

Profile your PHP script using Xdebug.

See example below to generate a cachegrind file named something like cachegrind.out. with appended timestamp within /tmp/ucpos folder.
php -d xdebug.profiler_enable=on -d xdebug.profiler_output_dir=/tmp/ucpos -d xdebug.profiler_output_name=cachegrind.out.%t index.php

Xdebugtoolkit.

Checkout xdebugtoolkit's latest stable version.
svn co http://xdebugtoolkit.googlecode.com/svn/tags/0.1.4/xdebugtoolkit/ xdebugtoolkit

Convert cachegrind.

Inside xdebugtoolkit folder, execute cg2dot.py and graphviz's dot to convert cachegrind file into dot and then into PNG format.

Example below will create /tmp/ucpos/1271979967.png from parsed cachegrind /tmp/ucpos/cachegrind.out.1271979967
./cg2dot.py /tmp/ucpos/cachegrind.out.1271979967 | dot -T png -o /tmp/ucpos/1271979967.png

References

Xdebug, http://xdebug.org/

Xdebugtoolkit, http://code.google.com/p/xdebugtoolkit/

Graphviz, http://www.graphviz.org/

Comments

Popular posts from this blog

Remote Deployment with Ant and Rsync

Site Performance Enhancement