I have an application that, when performing a background task, shows a progress bar with an estimated "estimated time" (for example, "the remaining 5 seconds") and an "estimated completion time" (for example, "completed at 12: 59:59"), or, as I call it, ETA.
The calculation algorithm of this ETA basically takes a "moving average" of progress over time:
1. Each progress event is added to the queue with the current time.
2. After a certain duration (for example, 10 seconds), items are removed from the queue.
3. ETA is extrapolated from the first and last elements in the queue.
Source code is available if you are interested: ETACalculator.cs
However, there is a jitter problem. As each progress event is added to the calculation, the ETA will be updated slightly. Let's say that the ETA only changes by 0.1s . This little shake makes ETA flutter easily. For example, instead of seeing a smooth progression from 5s, 4s, 3s, etc., I see 5-5-5-4-5-4-5-4-5-4-4-4-4.
I thought that I simply reduce updates to 1 per second, but then the progress indicator is less smooth, and I would really like the "actual" slowdowns to be displayed in real time.
I'm having trouble with a simple algorithm that reduces this jittery jitter. How to remove jitter?
source share