Best way to calculate ETA of an operation?

Maghis picture Maghis · May 12, 2009 · Viewed 12.2k times · Source

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

Answer

paxdiablo picture paxdiablo · May 12, 2009

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