EwmaNormalizedETA
Vladimir Bauer
1 year, 10 months ago
| 32 | 32 | // decorator to work correctly you have to measure each iteration's duration |
| 33 | 33 | // and pass it to one of the (*Bar).EwmaIncr... family methods. |
| 34 | 34 | func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator { |
| 35 | return EwmaNormalizedETA(style, age, nil, wcc...) | |
| 36 | } | |
| 37 | ||
| 38 | // EwmaNormalizedETA same as EwmaETA but with TimeNormalizer option. | |
| 39 | func EwmaNormalizedETA(style TimeStyle, age float64, normalizer TimeNormalizer, wcc ...WC) Decorator { | |
| 35 | 40 | var average ewma.MovingAverage |
| 36 | 41 | if age == 0 { |
| 37 | 42 | average = ewma.NewMovingAverage() |
| 38 | 43 | } else { |
| 39 | 44 | average = ewma.NewMovingAverage(age) |
| 40 | 45 | } |
| 41 | return MovingAverageETA(style, NewThreadSafeMovingAverage(average), nil, wcc...) | |
| 46 | return MovingAverageETA(style, NewThreadSafeMovingAverage(average), normalizer, wcc...) | |
| 42 | 47 | } |
| 43 | 48 | |
| 44 | 49 | // MovingAverageETA decorator relies on MovingAverage implementation to calculate its average. |