PHP Library to test loading speeds
I was wondering whether there is a simple PHP library to test the loading speed of a web page or a single resource sim开发者_运维技巧ilar to Google Page Speed and Yahoo! YSlow. The reason is that I'd like to build a web based alternative.
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/
$start=microtime(1);
copy($url,"/dev/null");
echo "$url page loading time is: ".round(microtime(1)-$start,4);
?
精彩评论