现在的位置: 首页 > 综合 > 正文

用 microtime() 对脚本的运行计时-来自php手册

2013年04月16日 ⁄ 综合 ⁄ 共 299字 ⁄ 字号 评论关闭

<?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";
?>

抱歉!评论已关闭.