diff --git a/_examples/spinnerBar/main.go b/_examples/spinnerBar/main.go index bdb3abd..f03939b 100644 --- a/_examples/spinnerBar/main.go +++ b/_examples/spinnerBar/main.go @@ -62,10 +62,13 @@ rng := rand.New(rand.NewSource(time.Now().UnixNano())) max := 100 * time.Millisecond for i := 0; i < total; i++ { + // start variable is solely for EWMA calculation + // EWMA's unit of measure is an iteration's taken time start := time.Now() time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10) - // since ewma decorator is used, we need to pass time.Since(start) - bar.Increment(time.Since(start)) + bar.Increment() + // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract + bar.DecoratorEwmaUpdate(time.Since(start)) } }() }