Using Federico’s plot-timeline Script With PHP
I am currently trying to profile a PHP application, so I tried to find a way to create a call graph. Since I didn’t want to strace() the entire Apache process (which probably wouldn’t have worked anyway) I remembered a posting that showed how to do it with Mono. So this still depended on strace, but since I liked the plot-timeline.py script from Federico’s performance-tools, I decided to simply fake some strace output.
If you need to do the same, try the following:
unset($tracer);
$tracer = new CallTracer('/tmp/trace.log');
function trace($_comment = '') {
global $tracer;
$tracer->trace($_comment);
}
python plot-timeline.py -o graph.png /tmp/trace.log
The result looks something like this:
