Many times we need to calculate the execution time of the PHP script to learn about the efficiency of the script, and so on. For example, there is a large section of PHP script, we need a fragment to get the script execution time method. First introduce the function to be used:
Timer function Runtime ($mode = 0) {static $t; if (! $mode) {$t = Microtime (); return; } $t 1 = microtime (); List ($m 0, $s 0) = Split ("", $t); List ($m 1, $s 1) = Split ("", $t 1);
Microtime () function
The Microtime () function returns the current Unix timestamp and the number of microseconds.
Microtime (get_as_float), parameter get_as_float, if the get_as_float parameter is given and its value is equivalent to TRUE, the function returns a floating-point number.
<?phpecho (Microtime ());? >
If called without optional arguments, this function returns a string in the format "msec sec", where the SEC is the number of seconds since the Unix era (0:00:00 January 1, 1970 GMT) and msec is the microsecond portion. The two parts of a string are returned in seconds.
Program output:
Now it's time to compute the timephased execution of the PHP script.
How the execution time of the PHP script is calculated in segments