views:

51

answers:

1

Hi, I want to know what is the best way to calculate the download speed of the clients using Java. I have searched on the internet and found that I have to download a file from the server and calculate the time before and after the download completes and to make it more specific - repeat this action for 3 times so I can have an average time. For me, the problem above doesn't work well, for localhost I got the results let's say close to reality but from server the results are a lot lower. I made a page filled with js,css(the size that I want to test), before enters calculate the startDate from the extended Action class(using struts) and on the 'onLoad()' event I made an ajax submit in which I got the endDate.StartDate-EndDate gave me the time...I forgot to mention, I set also that my jsp page isn't cached. Do you know other solutions?

Thanks,

Luisa

+1  A: 

On Linux you could just run the following from the command line.

time wget <some-url>

This will give you the elapsed time for the GET request as the "real" time. Of course, this gives you just the time taken to fetch the page contents. It won't tell give you the time for loading any images, stylesheets, scripts, etc that the page pulls in, or the time taken to render the page or execute any embedded javascript.

... for localhost I got the results let's say close to reality but from server the results are a lot lower.

Your previous method may actually have been giving you true results. It is not unusual for access via "localhost" to work faster than remote access, especially if there are slow network links, web proxies, etc in the route from the client to the server.

Stephen C