2nd February 2008 - 3 minutes read time
Sometimes is is necessary to see how long your PHP code runs for. This can be done using the following function and examples. This will convert the result of the php function microtime() into a float value.
function getmicrotime($t){
list($usec, $sec) = explode(" ",$t);
return ((float)$usec + (float)$sec);
}
Use this function to see how long something runs for. At the start of the code call the microtime() function and store the result at the start. At the end store the result of the microtime() function as the end and then use the two values to figure out how long the code took to run.