0

I want to know what is the best way to get the download speed.

My idea is to start a 1 second timer when the download starts that will display how many bytes have been downloaded during this 1 second.

Should I implement it this way, or is there's a better way?

user4582812
  • 591
  • 1
  • 4
  • 16

1 Answers1

1

You'll need to consider whether you want "instantaneous" speed, "average" speed, or "expected" speed and choose an algorithm based on that.

What you defined is basically "instantaneous" speed.

Measuring from the start of the download until the current time would be "average".

And some sort of weighted history would probably be closest to "expected". For that, see this StackOverflow question regarding how to estimate remaining download time.

Community
  • 1
  • 1
Brian White
  • 8,332
  • 2
  • 43
  • 67
  • Do you know what type of speed calculation does popular download managers or web browsers use? – user4582812 Apr 03 '15 at 00:37
  • 1
    Generally the last. You don't really care about what the speed _has been_; you care about what the speed _will be_ and thus how much longer the download is going to take. Let me update the answer with a link. – Brian White Apr 03 '15 at 02:55