470,596 Members | 1,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

measuring download speed

Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?

Thanks, - Dave
Jul 23 '05 #1
4 2812
D. Alvarado wrote:
Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?


You can't reliably detect the download speed as too many other things
can alter its results. Search the c.l.j archives on groups.google.com
for "determine download speed" and you can read the past discussions on it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
D. Alvarado wrote:
Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?


I do not have a link but this is not a hard one. All you need to know
is the size of the downloaded test data. Then you compute the number of
milliseconds passed between start and end of download and divide the
size by this value, getting the download speed in bytes/s, for example.
However, note that the real download speed may vary very much.

The test data could be the document itself where the client-side script
is included:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
...
<script type="text/javascript">
var start = new Date();
</script>
...
</head>

<body>
...
<script type="text/javascript">
var msPassed = new Date().getTime() - start.getTime();
var bytesPerMS = Math.round(byteSize / msPassed);
</script>
</body>
</html>

In IE, the value of byteSize can be obtained with
document.documentElement.outerHTML.length.

Or it could be a multimedia resource which size you know and which you
embed in a test document. With client-side J(ava)Script you could then
"start the timer" before it is loaded and "stop it" if it is loaded.
HTH

PointedEars
Jul 23 '05 #3
Thomas 'PointedEars' Lahn wrote:
D. Alvarado wrote:
Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?

I do not have a link but this is not a hard one. All you need to know
is the size of the downloaded test data. Then you compute the number of
milliseconds passed between start and end of download and divide the
size by this value, getting the download speed in bytes/s, for example.
However, note that the real download speed may vary very much.


And that "variation" is what makes your test useless. If I am
multi-tasking with a broadband connection, with 17 other applications
running, with low resources, and then reboot and try it again, then you
will get different results.

So, let me restate what has been said on many many occasions before now,
you can *not* _reliably_ determine the connection speed, you can only
try to *guess* the download speed at that particular time, and then its
still worthless.

Besides, coming from someone who preaches the "non-javascript" side of
scripting, your "solution" is definitely broken when script is disabled.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #4
JRS: In article <9f**************************@posting.google.com >, seen
in news:comp.lang.javascript, D. Alvarado <la***********@zipmail.com>
posted at Mon, 14 Jun 2004 14:05:54 :
Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?


<URL:http://www.merlyn.demon.co.uk/js-date1.htm> measures, if the
receiving computer is not distracted, the time taken to transfer the
majority of the page, and shows it at the end.

In the absence of cache effects, this gives a rough estimate of the
current download speed; not an entirely trustworthy one, but better than
nothing. It includes the time taken to render the page.

One might reasonably use it to decide whether to load a large graphic
unconditionally, or only on user request. If a 30 kB page was fetched
over a link in under a second, it is reasonable to believe that the link
is fast; if it took over a minute, that it is slow.

But the data must be treated with considerable caution.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mudge | last post: by
20 posts views Thread by upperclass | last post: by
2 posts views Thread by =?Utf-8?B?Z3JlYXRiYXJyaWVyODY=?= | last post: by
9 posts views Thread by Ross | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.