測試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;
相關文章
相關標籤/搜索