测试时打印时间节点,php封装好的有方法可以直接用,手册里面有,搜索microtime即可。下面是手册上的方法。
<?php
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float ()
{
list( $usec , $sec ) = explode ( " " , microtime ());
return ((float) $usec + (float) $sec );
}
$time_start = microtime_float ();
// Sleep for a while
usleep ( 100 );
$time_end = microtime_float ();
$time = $time_end - $time_start ;
echo "Did nothing in $time seconds\n" ;
?>