用于测试加载速度的 PHP 库

发布于 2024-08-29 07:23:05 字数 95 浏览 2 评论 0原文

我想知道是否有一个简单的 PHP 库来测试网页的加载速度或类似于 Google Page Speed 和 Yahoo! 的单个资源Y慢。 原因是我想构建一个基于网络的替代方案。

I was wondering whether there is a simple PHP library to test the loading speed of a web page or a single resource similar to Google Page Speed and Yahoo! YSlow.
The reason is that I'd like to build a web based alternative.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静水深流 2024-09-05 07:23:05

PageSpeed 和 YSlow 在浏览器中运行,不仅测量一个 URL 的加载,还测量除 @importurl 之外链接到该 URL 的所有资源的加载CSS 文件中的 () 指令和 DOM 加载时的 javascript 资源延迟加载。我怀疑这是否可以使用 PHP 轻松完成,而无需通过 服务器端 JS 引擎运行代码 也是如此。

考虑 Dojo 代码

dojo.require("dijit.form.Button");

或此 JavaScript 代码:

document.write('<script src="', 
               'http://example.com/other.js', 
               '" type="text/JavaScript"><\/script>');

考虑到可能的方法数量,这实际上不可能从 PHP 中捕获。如果您仍想尝试,请查看cURLDOMHTTP 扩展

或者考虑使用 JavaScript 从浏览器进行测量,例如 http://webwait.com/

PageSpeed and YSlow run in the browser and do not only measure loading of one URL, but also of all resources linked on that URL in addition to @import and url() directives in CSS files and javascript resources lazy loaded while the DOM is loading. I doubt this can be done easily/at all with PHP without running the code through a server side JS engine as well.

Consider this snippet of Dojo code:

dojo.require("dijit.form.Button");

or this JavaScript code:

document.write('<script src="', 
               'http://example.com/other.js', 
               '" type="text/JavaScript"><\/script>');

Given the number of possible approaches out there, this is virtually impossible to catch from PHP. If you still want to try, check out the cURL, DOM and HTTP extension.

Or consider measuring from the browser with JavaScript, e.g. something like http://webwait.com/

烟花易冷人易散 2024-09-05 07:23:05
$start=microtime(1);
copy($url,"/dev/null");
echo "$url page loading time is: ".round(microtime(1)-$start,4);

$start=microtime(1);
copy($url,"/dev/null");
echo "$url page loading time is: ".round(microtime(1)-$start,4);

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文