Codebase list golang-github-vbauerster-mpb / b20de61
startBlock to sbEta Vladimir Bauer 8 years ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2222
2323 total := 100
2424 name := "Single Bar:"
25 startBlock := make(chan time.Time)
25 sbEta := make(chan time.Time)
2626 // adding a single bar
2727 bar := p.AddBar(int64(total),
2828 mpb.PrependDecorators(
3131 // replace ETA decorator with "done" message, OnComplete event
3232 decor.OnComplete(
3333 // ETA decorator with default eta age, and width reservation of 4
34 decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 4}), "done",
34 decor.ETA(decor.ET_STYLE_GO, 0, sbEta, decor.WC{W: 4}), "done",
3535 ),
3636 ),
3737 mpb.AppendDecorators(decor.Percentage()),
4141 max := 100 * time.Millisecond
4242 for i := 0; i < total; i++ {
4343 // update start block time, required for ETA calculation
44 startBlock <- time.Now()
44 sbEta <- time.Now()
4545 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
4646 // increment by 1 (there is bar.IncrBy(int) method, if needed)
4747 bar.Increment()