开发者

Timing portions of a PHP script, including runtime of individual methods of objects?

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜