简体   繁体   中英

Measuring application running time in CakePHP

In my production server I need to check running time of my application (I made in my local machine already)
But when I put microtime() between beforeFilter and afterFilter of my AppController I get very small results, say it $runningTime=0.20 seconds.
But the time between writing address to my browser and seeing the output page is 100 times larger than runningTime.
I need to find out the leakage that makes my application slow. Is it possible to catch the time difference between I wrote address to browser and get the output on browser? Maybe I can find out the cause.
I found out TIME_START constant which seems like a wrapper for microtime() .

See below URL

CakePHP 1.3: Measuring Page Execution Time

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.

A running time of 0.2 seconds seems alright to me. If your script is running in 20 seconds, move te point where you start measuring more towards the start of the script and see the results.

Or .. use xdebug profiling to see where your cpu cycles are going.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM