JProfiler是Joomla!调试中非常重要的一个环节,尤其对于在代码速度优化过程中,通过JProfiler可以看到程序执行过程中,整个代码的执行到每一步测试点执行的时间。
要使用JProfiler首先要import也就是加入这一行:
jimport( 'joomla.utilities.profiler');
然后在你测试的起始点创建对象:
$profiler = new JProfiler();
在你任何确定的测试点,输出:
echo $profiler->mark( ' first testing' );
mark会在页面输出一个div,其中包含了从JProfiler对象创建开始,到当前测试点执行所花的时间,以及当前使用的内存。
下面是测试代码片段:
$profiler = new JProfiler();
//running..................
echo $profiler->mark( ' first testing ' );
$profiler = new JProfiler();
//running ........
echo $profiler->mark( ' 2nd testing ' );