Calculating download time based on bit rate.

C

Chase Preuninger

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);
}
 
K

Knute Johnson

Chase 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.)

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);
}


Are size and received in bytes? Is bitRate bytes or bits?
 
C

Chase Preuninger

my byterate was messed up. i forgot to set the last byte varible to
what it was last time I calculated it.
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top