views:

20

answers:

1

I was looking for a reliable, clean way to do advanced runtime reports for specific portions of a PHP script. What I'd love to do is dynamically time and track every method call of every object during script execution, log this information, and create a table/report at the end of the script for output.

I've thought about doing something along the lines of, in pseudocode:

class MagicTimingClass redefines *ALL_CLASSES* {
    public function __call($name, $args) {
        log_start_time();
        $return = run_the_method();
        log_end_time();
        return $return; // return original method results
    }
}

I know I can't do this, and I've looked into runkit/classkit for PHP but I'm not sure this will help me do exactly what I'm looking for.

I'm hoping to get out a report so I can determine what methods are causing my script to bottleneck without temporarily modifying my classes for this level of debugging and then un-modifying again when I need the code to go to production.

If anyone has any thoughts or leads that would be great! Thanks in advance

+3  A: 

You could use a profiler like Xdebug which would mean you wouldn't have to modify your code at all.

Yacoby
In the end this was the best solution. I did a whole bunch of research since I asked the question and that found xdebug, combined with WinCacheGrind, has proven to be an amazing combination of tools. Thank you!
theotherlight