Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CleanPct = 0.1
var WindowCap = 10000
Functions ¶
This section is empty.
Types ¶
type MovingAverage ¶
type MovingAverage struct {
// contains filtered or unexported fields
}
MovingAverage collates and determines the moving average of ticks. It collects ticks within fixed time window, then uses the count of ticks in the windows to compute the moving average.
func NewMovingAverage ¶
func NewMovingAverage(windowDur time.Duration) *MovingAverage
NewMovingAverage creates an instance of MovingAverage. windowDur is the lifespan of a window
func (*MovingAverage) Average ¶
func (m *MovingAverage) Average(dur time.Duration) float64
Average calculates the average of all derived moving averages of dur. dur must be divisible by the initial window duration without remainder. E.g if initial window duration is 10 seconds, then 10, 20, 30, 40 are valid values
func (*MovingAverage) Averages ¶
func (m *MovingAverage) Averages(dur time.Duration) []float64
Averages calculates the dur moving averages. dur must be divisible by the initial window duration without remainder. E.g if initial window duration is 10 seconds, then 10, 20, 30, 40 are valid values
func (*MovingAverage) Tick ¶
func (m *MovingAverage) Tick()
Tick increments the tick count of the current window and creates a new window if the current window has expired