tick

package
v0.0.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanPct = 0.1
View Source
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL