Skip to content

confusing dyn total example #144

@tcurdt

Description

@tcurdt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions