Munges an xdebug trace output with the source file, to make for easier analysis. Perhaps of use with large trace files (>20Gb etc).
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md
README.md
filter.py
report.py

README.md

xdebug-function-trace-code-annotation

Munges an xdebug trace output with the source file, to make for easier analysis. Perhaps of use with large trace files (>20Gb etc).

Usage

  • Run an xdebug function trace ( see http://xdebug.org/docs/execution_trace ) on some code that needs optimising.

    • Ensure the PHP ini setting for xdebug.trace_format is set to 1
  • Grab the output file (e.g. MyTraceFile.xt) and filter it with :

python filter.py Module/File.php MyTraceFile.xt > filtered.xt
  • Then, merge the filtered.xt into the source code producing a report -
python report.py filtered.xt ./path/to/Source/Code/Module/File.php > report.html

You'll see report.html looking a little like :

99  ....
100 foreach ($x as $y) {
101 $qty = $allocationRepo->getSomethingByXAndY($y, $location);	
      {'....->getSomethingByXAndY': {'avg_time': 0.018434527744934828, 'count': 774700, 'total_time': 14281.22864400101} }

102 if( ! $qty ) { continue ; }
103 ....

You could obviously repeat the above for all files within your application, however it's probably the case that you can pre-select the code that's more likely to be the bottleneck beforehand through simple visual analysis.