How to Create Graphical View of Xdebug's Cachegrind Output

This tutorial will teach us how to create graph out of xdebug's cachegrind file. The concept is very simple, Convert cachegrind into dot then convert dot into graph PNG format. First is create the cachegrind file using xdebug, then parse the cachegrind with dot to generate dot file, then convert dot file into PNG format. The advantage of this is that you can easily view your scripts performance.


Requirements
  • Xdebug
  • Xdebugtoolkit
  • Dot

Procedures

Profile your script using Xdebug to create cachegrind file.

php -d xdebug.profiler_enable=on -d xdebug.profiler_output_dir=PATH_TO_ANY_OUTPUT_DIR XmlParser.php

Checkout xdebugtoolkit's latest stable version.

svn co http://xdebugtoolkit.googlecode.com/svn/tags/0.1.4/xdebugtoolkit/ xdebugtoolkit

Convert cachegrind into dot format, then convert dot into PNG

./cg2dot.py CACHEGRIND_FILE | dot -Tpng -oResult.png


References

Comments

Popular posts from this blog

Remote Deployment with Ant and Rsync

Site Performance Enhancement