vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.31k stars 123 forks source link

ewma time going up? #59

Closed sedlund closed 4 years ago

sedlund commented 4 years ago

I must be doing something wrong, I'm hoping someone can spot it easily and help me out.

https://asciinema.org/a/emiUqPl3r9mIrj9CudPv0fJa3

The data below the bar is what I was calculating myself before finding this neat progress bar, but the eta on the bar seems to be going the wrong way fast?

code: https://gist.github.com/sedlund/dd27e52a21b443713eb7ece80d35d3d4

vbauerster commented 4 years ago

Hi! start := time.Now() at line 137, must be moved inside for loop. EWMA's unit of measure is an iteration's taken time. example. Also all those decor.WCSync... aren't necessary for single bar usage.

sedlund commented 4 years ago

Thanks!

I found that I also needed to slow my poll as well by inserting a sleep:

    time.Sleep(time.Millisecond * 1000)
    bar.SetCurrent(int64(curFrame), time.Since(start))
vbauerster commented 4 years ago

Not a problem! There is an average eta decorator available as well, which doesn't require to pass any duration into bar.SetCurrent.