Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Estimated time remaining does not take into account current iteration #105

Open
tchajed opened this issue Aug 15, 2021 · 1 comment
Open

Comments

@tchajed
Copy link

tchajed commented Aug 15, 2021

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()
}
@schollz
Copy link
Owner

schollz commented Apr 14, 2022

Could you please submit a PR to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants