Skip to content

Commit

Permalink
EwmaNormalizedETA
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Aug 16, 2024
1 parent 9502d24 commit 23b8427
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion decor/eta.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ func (f TimeNormalizerFunc) Normalize(src time.Duration) time.Duration {
// decorator to work correctly you have to measure each iteration's duration
// and pass it to one of the (*Bar).EwmaIncr... family methods.
func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
return EwmaNormalizedETA(style, age, nil, wcc...)
}

// EwmaNormalizedETA same as EwmaETA but with TimeNormalizer option.
func EwmaNormalizedETA(style TimeStyle, age float64, normalizer TimeNormalizer, wcc ...WC) Decorator {
var average ewma.MovingAverage
if age == 0 {
average = ewma.NewMovingAverage()
} else {
average = ewma.NewMovingAverage(age)
}
return MovingAverageETA(style, NewThreadSafeMovingAverage(average), nil, wcc...)
return MovingAverageETA(style, NewThreadSafeMovingAverage(average), normalizer, wcc...)
}

// MovingAverageETA decorator relies on MovingAverage implementation to calculate its average.
Expand Down

0 comments on commit 23b8427

Please sign in to comment.