Re-rendering the bar in the middle of an iteration updates the time since start, but the time remaining doesn't take into account the current iteration.
Here's a simple example video, and the code to generate it below. The rate is a constant 1 it/s, but progress comes in some large spurts. I have a goroutine rendering the bar regularly to keep the output up-to-date.
package main
import (
"time"
"github.com/schollz/progressbar/v3"
)
func main() {
bar := progressbar.NewOptions(10, progressbar.OptionSetPredictTime(true))
go func() {
for !bar.IsFinished() {
bar.RenderBlank()
time.Sleep(65 * time.Millisecond)
}
}()
time.Sleep(1 * time.Second)
bar.Add(1)
time.Sleep(5 * time.Second)
bar.Add(5)
time.Sleep(4 * time.Second)
bar.Add(4)
bar.Finish()
}
Re-rendering the bar in the middle of an iteration updates the time since start, but the time remaining doesn't take into account the current iteration.
Here's a simple example video, and the code to generate it below. The rate is a constant 1 it/s, but progress comes in some large spurts. I have a goroutine rendering the bar regularly to keep the output up-to-date.