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:
(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.
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.
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.
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 ;-)
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%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With