progressbar icon indicating copy to clipboard operation
progressbar copied to clipboard

Estimated time remaining does not take into account current iteration

Open tchajed opened this issue 4 years ago • 1 comments

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()
}

tchajed avatar Aug 15 '21 14:08 tchajed

Could you please submit a PR to fix?

schollz avatar Apr 14 '22 16:04 schollz