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.
The index.php 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:
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.
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". :)