||09-14-2007 11:14 PM
Script Execution Time Class
This script will calculate the execution time of your PHP scripts. The features are as follows:
- Automatic Calculation of the Execution Time;
- Notification upon Unexpectedly Long Execution Time;
- Available in both PHP4 and PHP5 Flavours;
- Set the Output's Precision.
bundled with the script contains the instructions on how to use it. The file also contains example code which can be removed. All you need to calculate and output the execution time is:
1 - Include (SSI) the execution time class to your page:
2 - Call the start function to begin the timing:
3 - Call the end function to end the timing:
4 - Output the total execution time using the display function:
The rest of the code contained in index.php
can be removed as it is only there for test purposes. Once you have downloaded the file, open up TalkPHPTimer.class.php
and replace your e-mail address with the default e-mail address in the TPHP_TIMER_ADDRESS
constant. The constants used in the script are:
Article: For the TalkPHP article on execution times, please see this page
- TPHP_TIMER_ADDRESS - The e-mail address to send a warning to when the execution time exceeds the specified as set in the TPHP_TIMER_EXCESSIVE constant;
- TPHP_TIMER_EXCESSIVE - The amount of seconds that the execution time must not exceed. If it does, an e-mail will be sent to the administrator's email as specified in the TPHP_TIMER_ADDRESS constant.
- TPHP_TIMER_PRECISION - How many numbers that should appear after the decimal when returning the execution time. Setting it to 0 means no rounding what-so-ever.
||09-14-2007 11:25 PM
For the PHP5 version: as of PHP 5.0.0 there is a single, optional argument for microtime which is get_as_float (bool). Using this argument would allow you to make your start/stop functions "one liners". :)
||09-14-2007 11:36 PM
Updated. I do assume you meant like that. I noticed the optional argument but I didn't actually check PHP.net to understand it further. Thanks for pointing it out.
|All times are GMT. The time now is 06:03 PM.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0