测试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;
posted @ 2018-10-15 20:34  犀利瓜  阅读(812)  评论(0编辑  收藏  举报