tick

package
v0.1.8-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: GPL-3.0 Imports: 3 Imported by: 1

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 {
	sync.Mutex
	// contains filtered or unexported fields
}

MovingAverage collates ticks and determines the moving average of the collated ticks. It collects ticks within fixed time window, then uses the count of ticks in the windows to calculate 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