PHP获取页面加载统计信息-如何衡量php脚本执行/加载时间
问题描述:
标题中的内容:
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
页脚中的内容:
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in ' . $total_time . ' seconds.';
输出:1292008977.54秒内生成的页面.
Output: Page generated in 1292008977.54 seconds.
有人可以帮我弄清楚为什么结果不正确吗?我正在使用PHP5.
Can someone please help me figure out why the result is not right?? I am using PHP5.
答
microtime()
返回具有 microseconds 的当前 Unix时间戳.我看不到有任何数学方法可以将微秒转换为秒.
microtime()
returns the current Unix timestamp with microseconds. i don't see any math there that does the conversion from microseconds to seconds.
microtime(true)
以浮点数形式返回时间,该时间以 秒
microtime(true)
returns the time as a float in seconds