用于获取页面文件大小和加载时间的 PHP 函数
与我的上一个问题类似,我想要一个 PHP 函数,它可以采用本地路径并告诉我(a)HTML、CSS、JS 和图像的总文件大小是多少,以及(b)总负载是时候浏览此页面了。我认为像 YSlow 一样,但作为一个 PHP 函数。
有什么想法吗?我环顾四周,想知道我可以使用 CURL 来实现这个目的吗?即使我需要检查我自己的服务器上的路径?谢谢!
更新:
读完评论后,意识到我错了。相反,想知道是否有一种方法可以以编程方式获取页面的 YSlow 分数(或类似的性能分数)。我认为它需要访问充当客户端的第三方网站。我基本上试图循环访问一组页面并获得某种性能指标。谢谢!
Similar to my last question, I'd like to have a PHP function that can take a local path and tell me (a) how much the total file size is for HTML, CSS, JS and images, and (b) the total load time for this page. Like YSlow I think, but as a PHP function.
Any thoughts? I looked around and was wondering can I use CURL for this? Even though I need to check paths that are on my own server? thanks!
Update:
After reading the comments, realizing I'm off base. Instead wondering is there a way programatically get a YSlow score for a page (or similar performance score). I assume it would need to hit a third-party site that would act as the client. I'm basically trying to loop through a group of pages and get some sort of performance metric. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件大小。
加载时间
加载时间取决于连接速度和文件大小。我看到您指定您正在本地读取文件。您可以检测读取这些文件所需的时间,但这不会是外部用户的页面加载时间。
For the filesize.
Loadtime
Loadtime depends on the connection speed and the filesize. And I see that you specify that you are reading locally the files. You can detect how much time it take you to read those files but this will not be the loadtime for the page for an external user.