php自定义获取脚本执行时间函数

function get_execution_time()
{
    static $microtime_start = null;
    if($microtime_start === null)
    {
        $microtime_start = microtime(true);
        return 0.0;
    }
    return microtime(true) - $microtime_start;
}
//  生成一个包含10万个元素的数组并打乱
$arr1 = range(0, 99999);
shuffle($arr1);
get_execution_time();

//  执行排序
sort($arr1);

//  计算数组排序所需时间
echo "花费了 " . get_execution_time() . " s <br>";

# output
// 花费了 0.113119840622 s