Skip to content

Instantly share code, notes, and snippets.

@Halleck45
Last active August 29, 2015 13:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Halleck45/8936038 to your computer and use it in GitHub Desktop.
Save Halleck45/8936038 to your computer and use it in GitHub Desktop.
Run xdebug tracefile-analyzer on script
#!/bin/bash
# Usage
# ./profiler.sh /path/to/phpfile.php arg1 arg2 ...
if [ ! -f tracefile-analyser.php ]
then
echo get tracefile-analyser
wget https://raw.github.com/derickr/xdebug/master/contrib/tracefile-analyser.php
fi
# xdebug enabled ?
has=$(php -v |grep -c 'Xdebug')
if [ "$has" -lt 1 ]; then
echo xDebug not found
exit 0
fi
# runs script
PID=$$
FILENAME=trace$PID
php -d xdebug.auto_trace=1 -d xdebug.trace_format=1 -d xdebug.trace_output_dir=/tmp -d xdebug.trace_output_name=$FILENAME $@ > /dev/null
# check trace
if [ ! -f /tmp/$FILENAME.xt ]
then
echo cannot create trace
exit 0
fi
# runs analyze
echo trace created in /tmp/$FILENAME.xt
echo run analyze
php tracefile-analyser.php /tmp/$FILENAME.xt time-own
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment