Codebase list golang-github-vbauerster-mpb / ae6270d
single bar examlpe use AverageETA Vladimir Bauer 6 years ago
2 changed file(s) with 2 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
4444 // replace ETA decorator with "done" message, OnComplete event
4545 decor.OnComplete(
4646 // ETA decorator with ewma age of 60, and width reservation of 4
47 decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WC{W: 4}), "done",
47 decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
4848 ),
4949 ),
5050 mpb.AppendDecorators(decor.Percentage()),
5252 // simulating some work
5353 max := 100 * time.Millisecond
5454 for i := 0; i < total; i++ {
55 // start variable is solely for EWMA calculation
56 // EWMA's unit of measure is an iteration's duration
57 start := time.Now()
5855 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
5956 bar.Increment()
60 // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
61 bar.DecoratorEwmaUpdate(time.Since(start))
6257 }
6358 // wait for our bar to complete and flush
6459 p.Wait()
2222 decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
2323 // replace ETA decorator with "done" message, OnComplete event
2424 decor.OnComplete(
25 // ETA decorator with ewma age of 60, and width reservation of 4
26 decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WC{W: 4}), "done",
25 decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
2726 ),
2827 ),
2928 mpb.AppendDecorators(decor.Percentage()),
3130 // simulating some work
3231 max := 100 * time.Millisecond
3332 for i := 0; i < total; i++ {
34 // start variable is solely for EWMA calculation
35 // EWMA's unit of measure is an iteration's duration
36 start := time.Now()
3733 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
3834 bar.Increment()
39 // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
40 bar.DecoratorEwmaUpdate(time.Since(start))
4135 }
4236 // wait for our bar to complete and flush
4337 p.Wait()