Skip navigation.
 
mlRe: how to implement ETA
FROM : Jens Alfke
DATE : Sun Jun 01 18:09:07 2008

On 1 Jun '08, at 5:50 AM, Nick Rogers wrote:

> I want to show time remaining while executing a loop.
> How to go about it?


Basic algebra, mostly. Compute the elapsed time (current time minus 
time the loop started), divide by the number of iterations so far 
[that gives you the time per iteration] and multiply by the number of 
iterations remaining.

Two caveats:
(1) It's best not to show this until you've gone through several 
iterations, because early on the results can be very inaccurate and 
vary wildly from one iteration to the next. I usually wait till the 
loop's about 10% done.
(2) This works best if the iterations take a consistent amount of 
time. If they vary, then the farther the progress gets, the more the 
estimate is based on past timing and not on the current speed. For 
example, if you're downloading, and the network slows down halfway 
through, the estimate won't be accurate because it's based mostly on 
the earlier faster speed. Fixing this isn't rocket science (or tensor 
calculus) and is left as an exercise for the reader ;)

—Jens

Related mailsAuthorDate
mlhow to implement ETA Nick Rogers Jun 1, 14:50
mlRe: how to implement ETA Jens Alfke Jun 1, 18:09
mlRe: how to implement ETA William Squires Jun 3, 03:06