CakePHP 1.3: Measuring Page Execution Time

此生再无相见时 提交于 2019-12-06 12:49:33

Just in case anyone else is curious, I solved this by adding the following code to my layout.ctp. You could also do this in the controller and pass it in as a variable, which might be a little more classic MVC-friendly, but I wanted this on every page of the site without duplicating code in each controller.

Page rendered in <?php echo round((getMicroTime() - $_SERVER['REQUEST_TIME']) * 1000) ?>ms.

Use Debug Kit. Among other functionality, you can grab the total execution time via

DebugKitDebugger::requestTime()

This may not be the "right" way to do it, but you can add the following PHP code back into app/webroot/index.php (at the very end). Then if you have debug on > 0, you'll get the old 1.2 functionality back.

if (Configure::read() > 0) {
    echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!