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

confusing dyn total example #144

Open
tcurdt opened this issue Oct 30, 2024 · 0 comments
Open

confusing dyn total example #144

tcurdt opened this issue Oct 30, 2024 · 0 comments

Comments

@tcurdt
Copy link

tcurdt commented Oct 30, 2024

I looked at the dyn total example and don't quite understand it.
This is what I tried:

p := mpb.New(mpb.WithWidth(64))
success := p.AddBar(
    0,
    mpb.PrependDecorators(
        decor.Name("Success", decor.WC{C: decor.DSyncWidth}),
    ),
    mpb.AppendDecorators(
        decor.CountersNoUnit("%d / %d", decor.WCSyncWidth),
    ),
)
success.SetTotal(0, true)

max := 100 * time.Millisecond
for i := 0; i < total; i++ {
    time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)

    ok := rand.Int63n(100)
    ko := rand.Int63n(100)
    success.SetCurrent(ok)
    success.SetTotal(ok+ko, false)
}

p.Wait()

I want to see the percentage or ratio of ok vs ko.
But it just shows

Success [--------------------------------------------------------------]  0 / 0
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

1 participant