开发者

Website loading time programmatically

I'm looking for a solution on monitoring website loading time Programmatically I build my web application on Codeigniter and can use the benchmark class for getting the server site execution time but what I need is the total loading time of a website from the time a server-side call is done until all the contents of the website have been loaded. I'm currently using a JavaScript function that subtracts the time before and after the onload event but I'm not sure about the accuracy of this method.

Please note that I'm not interested in "Best Practices" and recommendations for improving speed like those offered by Google speed, YSlow, etc

Is their any client-side library or something that I could reuse for accurate loading time, similar to those provided by the Google Chrome developer tools that 开发者_C百科provide loading time for images, scripts, etc?


Yes.

tl;dr

Use a headless browser to measure the loading times. One example of doing so is Website Loading Time.

Long version

I created a side-project to measure actual loading times. It uses Node and Nightmare to manipulate a headless ("invisible") web browser. Once all of the resources are loaded, it reports the number of milliseconds it took to fully load the page.

One nice feature that would be useful for you is that it loads the webpage repeatedly. So, you could load the page multiple times and then average the values for a nice, round value. Also, since this script runs on the command-line, it's trivial to install on different machines and get actual loading times from various locations. (Load time depends not just on the server, but also the client and intermediaries)

Example usage:

website-loading-time rinogo$ node website-loading-time.js https://google.com
1657
967
1179
1005
1084
1076
...

You mentioned that you are trying to measure load time programmatically. Since this is a command-line utility, you could run it from your code and parse the result.

https://github.com/rinogo/website-loading-time

Disclosure: I am the author of this project.


The answer is no I'm afraid, Chrome dev tools, Firebug, IE Dev Toolbar are the only options from a browser perspective. Any client side script will be part of the load and subject to delays before it starts execution.

There are tools to intercept and monitor the HTTP requests that can also give you this kind of information but again, it's not something that you can do without installation or user interaction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜