测试php函数的执行时间

使用microtime() 能够将时间精确到秒以后4位,经过bcsub()避免得到科学计数法结果。code

<?
function add($a, $b) {
    return $a + $b;
}

$start = microtime(true);


$result = add(99, 88888);

$end = microtime(true);
$usedTime = bcsub($end, $start, 4);

echo $usedTime;
相关文章
相关标签/搜索