Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to calculate ETA of an operation?

I am looking for the best way to calculate ETA of an operation (IE: file download) using a linear progress information.

Lets say that I have the following method that gets called:

void ReportProgress(double position, double total)
{
    ...
}

I have a couple of ideas:

  • calculate the progress in a set amount of time (like last 10s) and use that speed as an average speed for the operation
  • keep a set of the last x progresses that has been reported, calculate the speed of each increment and use the average
like image 647
Maghis Avatar asked May 12 '09 13:05

Maghis


People also ask

How do you do ETA in Excel?

(period/fullstop) to open the panel. Choose the Symbols tab (the third of the top row icons), then the Language Symbols section which is marked by the capital Ω … handy that. To find the Eta – lower case η, look within the first row.

How is ETA calculated in aviation?

ETA is purely a statistical term and based on simple formula i.e. Time (ETA) is equal to distance divided by speed of travel, transportation.

How is ETA calculated in zone description?

Translate the Zone Time and Date of Departure Port to GMT and Date of Departure. Calculate the elapsed time of the voyage, including layovers, and apply it to GMT of Departure to find the GMT and Date of Arrival. Apply the reversed ZD (Zone Description) of the Arrival Port to GMT to find the ZT and Date of Arrival.


2 Answers

I actually despise both those ideas because they've both bitten me before as a developer.

The first doesn't take into account the situation where the operation actually gets faster, it says that there's 10 minutes to go and I come back after 3 and it's finished.

The second doesn't take into account the operation getting slower - I think Windows Explorer must use this method since it always seems to take 90% of the time copying 90% of the files, then another 90% of the time copying that last 10% of the files :-).

I've long since taken to calculating both those figures and averaging them. The clients don't care (they didn't really care about the other two option either, they just want to see some progress) but it makes me feel better, and that's really all I care about at the end of the day ;-)

like image 148
paxdiablo Avatar answered Oct 25 '22 12:10

paxdiablo


Something like this should do the trick:

void ReportProgress(double position, double total)
{
    static TimeType startTime;

    if (position == 0)
    {
        startTime = GetTime();
        return; // to avoid a divide-by-zero error
    }

    TimeType elapsedTime = GetTime() - startTime;
    TimeType estimatedRemaining = elapsedTime * total / position;
    TimeType estimatedEndTime = GetTime() + estimatedRemaining;

    // Print the results here
}

The estimate gets closer to the truth as the progress approaches 100%

like image 44
e.James Avatar answered Oct 25 '22 14:10

e.James