Tools for processing Xdebug trace files. Written in the Vala language.
Vala Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Vala Xdebug Tools

This package has tools that are useful for parsing Xdebug trace data. If you are not sure how to collect Xdebug trace data, see the section 'Collecting Data with Xdebug' below.

Note: This package works, but isn't actively maintained. If you would like to help maintain trace_analzyer, please file an issue in the issue queue.


Install the Vala environment. (On Mac OS X, brew install vala libgee)


    valac --pkg gio-2.0 --pkg gee-0.8 src/*.vala -o trace_analyzer

(Or just make build)


    ./trace_analyzer some_trace_file.xt


The trace analyzer has a number of features. In its basic form, it simply prints performance data about time and memory usage in a trace file.

To get an idea as to how it works, try this:

trace_analyzer --help

CSV ouput

By running trace_analzer -c some_file, you can generate CSV output. This explains the columns.

Columns of output:

  • function: Name of the function called
  • calls: Number of times the function was called
  • time_inclusive: Aggregated time for calling this function and all children functions
  • memory_inclusive: Aggregated memory for calling this function
  • time_own: Aggregated time for calling this function, MINUS the aggregated time for calling its children
  • memory_own: Aggregated memory for this function, MINUS the aggregated memory of children functions
  • time_own_min: The fastest this function was executed
  • time_own_max: The slowest this function executed
  • time_own_avg: The average time it took to execute the function
  • memory_own_min: The minimum amount of memory this required to run
  • memory_own_max: The maximum amount of memory this required to run
  • memory_own_avg: The average memory consumed by this function

Note that memory numbers are somewhat suspect because of PHP's garbage collection, which may deallocate memory between function entry and function exit, essentially creating a negative memory usage number.

Collecting Data with Xdebug

Example php.ini config for Xdebug:

xdebug.auto_trace = 1
xdebug.trace_format = 1
xdebug.trace_output_name = php-trace.%t

The second one is the most important: Set the tracing format to 1.

Developers: Build Your Own Trace Tools

Included in this tool is a straightforward library for building your own tracefile analyzers. In a nutshell, here's how you do it:

  1. Create a class that extends XdebugTools.TraceObserver
  2. Write a simple wrapper that creates a new XdebugTools.TraceParser()
  3. Register your observer (e.g. trace_parser.register(my_trace_observer))
  4. Parse the file (e.g. trace_parser.parse())

Why Vala?

Why was this tool written in Vala instead of PHP? There are two reasons:

  1. Vala is compiled to a native executable, and is thus substantially faster than its PHP equivalent. This is important when trace files start to get huge.
  2. I think Vala is a fantastic language, and thus have used it here.


Thanks to Derick Rethans, who posted a simple PHP tool for parsing Xdebug trace files.


This script was written and originally tested on Mac OS X using the homebrew package of Vala and Gee. It was written in TextMate using the Vala bundle. Subsequently, this has been tested on Debian GNU/Linux.

There is no reason why this shouldn't compile and execute on any system that supports Vala.