测试php函数的执行时间

使用microtime() 可以将时间精确到秒之后4位,通过bcsub()避免获得科学计数法结果。

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

$start = microtime(true);


$result = add(99, 88888);

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

echo $usedTime;
原文地址:https://www.cnblogs.com/gelu/p/9794487.html