PHP获取页面加载统计信息-如何衡量php脚本执行/加载时间 [英] PHP Get Page Load Stats - How to measure php script execution / load time

查看:160
本文介绍了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

这篇关于PHP获取页面加载统计信息-如何衡量php脚本执行/加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆