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.

  • Xdebug
  • Xdebugtoolkit
  • Dot


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 xdebugtoolkit

Convert cachegrind into dot format, then convert dot into PNG

./ CACHEGRIND_FILE | dot -Tpng -oResult.png