Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate estimated remaining download time

Tags:

java

android

I have a code which download file from URL.
I have a two parameters that calculated all time for downloading :

Long start = System.nanoTime();
// downloading...
Long end = System.nanoTime();

I need to measure estimated remaining time to end of downloading. How i can do that?

like image 738
Sergey Shustikov Avatar asked Jun 02 '15 14:06

Sergey Shustikov


People also ask

How long should a 1 Gig download take?

A 100Mbps (megabits per second) fibre connection will give you a download speed of 12.5MBps (megabytes per second). A 1GB file is equal to 1024MB, so it should take 81.9 seconds to download the file.

How long should 300 MB take to download?

If you're calculating the download time for another file, it's important to remember that 300Mbps stands for 300 Megabits per second (where 8 Megabits are equal to one MegaByte). For this reason, if you're downloading a 300MB (300 MegaByte) file, it will take you 8 seconds to do this and not one second.


1 Answers

It was simply, sorry 4 your time.

For future searchers :

When you start downloading save timestamp :

Long startTime = System.nanoTime();

to calculate average remaining speed :

 Long elapsedTime = System.nanoTime() - startTime;
 Long allTimeForDownloading = (elapsedTime * allBytes / downloadedBytes);
 Long remainingTime = allTimeForDownloading - elapsedTime;
like image 182
Sergey Shustikov Avatar answered Oct 04 '22 05:10

Sergey Shustikov