Codebase list golang-github-vbauerster-mpb / 010bd5c
example update Vladimir Bauer 6 years ago
1 changed file(s) with 5 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6161 rng := rand.New(rand.NewSource(time.Now().UnixNano()))
6262 max := 100 * time.Millisecond
6363 for i := 0; i < total; i++ {
64 // start variable is solely for EWMA calculation
65 // EWMA's unit of measure is an iteration's taken time
6466 start := time.Now()
6567 time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10)
66 // since ewma decorator is used, we need to pass time.Since(start)
67 bar.Increment(time.Since(start))
68 bar.Increment()
69 // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
70 bar.DecoratorEwmaUpdate(time.Since(start))
6871 }
6972 }()
7073 }