![]() |
Calculating the Execution Time
The execution time is perhaps one of the most crucial element to your scripts. Very few individuals are going to want to wait around while your PHP script performs several server-intensive actions. The more server-intensive you make it, the more the user has to wait for those actions to complete before displaying the HTML.
Although this isn't an article on how to make your scripts more efficient. It is an article on how you can monitor the execution time and identify bottlenecks! The execution time can be determined by calculating the microtime at the beginning and at the end of your PHP script. I am using TalkPHP's timer class as the example here - this can be downloaded for free, see the link at the end of the article. PHP Code:
PHP Code:
Once we have the 2 times stored in member variables, we can calculate how long the execution time took. Keep in mind that the start function would be called at the beginning and then stop at the very end. Our display function will then deduct 1 from the other to calculate the execution time. PHP Code:
Once we have done that we can echo out our results. The result would be something like the following: Quote:
|
| All times are GMT. The time now is 01:17 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0