Question

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.

Was it helpful?

Solution

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/

OTHER TIPS

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

?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top