Calculating download time based on bit rate.  
Author Message
Chase Preuninger





PostPosted: 2008-4-18 10:06:00 Top

java-programmer, Calculating download time based on bit rate. I have the bps rate that the document is downloading at, the size of
the the document, and how much has been downloaded but I cant seem to
calculate the ETA for it to finish (all I need for now it the time in
seconds.)

for a 9mb file it says 2 seconds left when that is clearly wrong
considering that it takes around 1 minute to finish.

private long getSecondsLeft(long bitRate, long received, long
size)
{
return (bitRate != 0 ? (size - received) / bitRate : -1);
}
 
Chase Preuninger





PostPosted: 2008-4-18 20:02:00 Top

java-programmer >> Calculating download time based on bit rate. bytes
 
Andrea Francia





PostPosted: 2008-4-18 20:04:00 Top

java-programmer >> Calculating download time based on bit rate. Chase Preuninger wrote:
> bytes
Please quote the relevant part of message you are replying to.

--
Andrea Francia
http://www.andreafrancia.it/
 
 
Chase Preuninger





PostPosted: 2008-4-18 20:15:00 Top

java-programmer >> Calculating download time based on bit rate. my byterate was messed up. i forgot to set the last byte varible to
what it was last time I calculated it.
 
 
Roedy Green





PostPosted: 2008-4-22 12:57:00 Top

java-programmer >> Calculating download time based on bit rate. On Thu, 17 Apr 2008 19:05:38 -0700 (PDT), Chase Preuninger
<email***@***.com> wrote, quoted or indirectly quoted someone
who said :

>I have the bps rate that the document is downloading at, the size of
>the the document, and how much has been downloaded but I cant seem to
>calculate the ETA for it to finish (all I need for now it the time in
>seconds.)

Part of your problem is the download rate changes over time, so the
best you can do is work out the moving average and extraplate the
remaining time every second or so.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com