`

计算程序运行的时间

PHP 
阅读更多
参考是PHP手册
<?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";
?> 


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics