Documentation ¶
Overview ¶
Package measurements provides measurement reading implementations
Index ¶
- type ExponentialAverageMeasurement
- func (m *ExponentialAverageMeasurement) Add(value float64) (float64, bool)
- func (m *ExponentialAverageMeasurement) Get() float64
- func (m *ExponentialAverageMeasurement) Reset()
- func (m *ExponentialAverageMeasurement) String() string
- func (m *ExponentialAverageMeasurement) Update(operation func(value float64) float64)
- type ImmutableSampleWindow
- func (s *ImmutableSampleWindow) AddDroppedSample(startTime int64, maxInFlight int) *ImmutableSampleWindow
- func (s *ImmutableSampleWindow) AddSample(startTime int64, rtt int64, maxInFlight int) *ImmutableSampleWindow
- func (s *ImmutableSampleWindow) AverageRTTNanoseconds() int64
- func (s *ImmutableSampleWindow) CandidateRTTNanoseconds() int64
- func (s *ImmutableSampleWindow) DidDrop() bool
- func (s *ImmutableSampleWindow) MaxInFlight() int
- func (s *ImmutableSampleWindow) SampleCount() int
- func (s *ImmutableSampleWindow) StartTimeNanoseconds() int64
- func (s *ImmutableSampleWindow) String() string
- type MinimumMeasurement
- type SimpleExponentialMovingAverage
- type SimpleMovingVariance
- type SingleMeasurement
- type WindowlessMovingPercentile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExponentialAverageMeasurement ¶
type ExponentialAverageMeasurement struct {
// contains filtered or unexported fields
}
ExponentialAverageMeasurement is an exponential average measurement implementation.
func NewExponentialAverageMeasurement ¶
func NewExponentialAverageMeasurement( window int, warmupWindow int, ) *ExponentialAverageMeasurement
NewExponentialAverageMeasurement will create a new ExponentialAverageMeasurement
func (*ExponentialAverageMeasurement) Add ¶
func (m *ExponentialAverageMeasurement) Add(value float64) (float64, bool)
Add a single sample and update the internal state.
func (*ExponentialAverageMeasurement) Get ¶
func (m *ExponentialAverageMeasurement) Get() float64
Get the current value.
func (*ExponentialAverageMeasurement) Reset ¶
func (m *ExponentialAverageMeasurement) Reset()
Reset the internal state as if no samples were ever added.
func (*ExponentialAverageMeasurement) String ¶
func (m *ExponentialAverageMeasurement) String() string
func (*ExponentialAverageMeasurement) Update ¶
func (m *ExponentialAverageMeasurement) Update(operation func(value float64) float64)
Update will update the value given an operation function
type ImmutableSampleWindow ¶
type ImmutableSampleWindow struct {
// contains filtered or unexported fields
}
ImmutableSampleWindow is used to track immutable samples atomically.
func NewDefaultImmutableSampleWindow ¶
func NewDefaultImmutableSampleWindow() *ImmutableSampleWindow
NewDefaultImmutableSampleWindow will create a new ImmutableSampleWindow with defaults
func NewImmutableSampleWindow ¶
func NewImmutableSampleWindow( startTime int64, minRTT int64, sum int64, maxInFlight int, sampleCount int, didDrop bool, ) *ImmutableSampleWindow
NewImmutableSampleWindow will create a new ImmutableSampleWindow with defaults
func (*ImmutableSampleWindow) AddDroppedSample ¶
func (s *ImmutableSampleWindow) AddDroppedSample(startTime int64, maxInFlight int) *ImmutableSampleWindow
AddDroppedSample will create a new immutable sample that was dropped.
func (*ImmutableSampleWindow) AddSample ¶
func (s *ImmutableSampleWindow) AddSample(startTime int64, rtt int64, maxInFlight int) *ImmutableSampleWindow
AddSample will create a new immutable sample for which to use.
func (*ImmutableSampleWindow) AverageRTTNanoseconds ¶
func (s *ImmutableSampleWindow) AverageRTTNanoseconds() int64
AverageRTTNanoseconds returns the average RTT in the sample window. Excludes timeouts and dropped rtt.
func (*ImmutableSampleWindow) CandidateRTTNanoseconds ¶
func (s *ImmutableSampleWindow) CandidateRTTNanoseconds() int64
CandidateRTTNanoseconds returns the candidate RTT in the sample window. This is traditionally the minimum rtt.
func (*ImmutableSampleWindow) DidDrop ¶
func (s *ImmutableSampleWindow) DidDrop() bool
DidDrop returns True if there was a timeout.
func (*ImmutableSampleWindow) MaxInFlight ¶
func (s *ImmutableSampleWindow) MaxInFlight() int
MaxInFlight returns the maximum number of in-flight observed during the sample window.
func (*ImmutableSampleWindow) SampleCount ¶
func (s *ImmutableSampleWindow) SampleCount() int
SampleCount is the number of observed RTTs in the sample window.
func (*ImmutableSampleWindow) StartTimeNanoseconds ¶
func (s *ImmutableSampleWindow) StartTimeNanoseconds() int64
StartTimeNanoseconds returns the epoch start time in nanoseconds.
func (*ImmutableSampleWindow) String ¶
func (s *ImmutableSampleWindow) String() string
type MinimumMeasurement ¶
type MinimumMeasurement struct {
// contains filtered or unexported fields
}
MinimumMeasurement implements a minimum value measurement
func (*MinimumMeasurement) Add ¶
func (m *MinimumMeasurement) Add(sample float64) (float64, bool)
Add will compare the sample and save if it's the minimum value.
func (*MinimumMeasurement) Get ¶
func (m *MinimumMeasurement) Get() float64
Get will return the current minimum value
func (*MinimumMeasurement) Reset ¶
func (m *MinimumMeasurement) Reset()
Reset will reset the minimum value to 0.0
func (*MinimumMeasurement) String ¶
func (m *MinimumMeasurement) String() string
func (*MinimumMeasurement) Update ¶
func (m *MinimumMeasurement) Update(operation func(value float64) float64)
Update will update the value given an operation function
type SimpleExponentialMovingAverage ¶ added in v0.1.6
type SimpleExponentialMovingAverage struct {
// contains filtered or unexported fields
}
SimpleExponentialMovingAverage implements a simple exponential moving average this implementation only uses a single alpha value to determine warm-up time and provides a mean approximation
func NewSimpleExponentialMovingAverage ¶ added in v0.1.6
func NewSimpleExponentialMovingAverage( alpha float64, ) (*SimpleExponentialMovingAverage, error)
NewSimpleExponentialMovingAverage creates a new simple moving average
func (*SimpleExponentialMovingAverage) Add ¶ added in v0.1.6
func (m *SimpleExponentialMovingAverage) Add(value float64) (float64, bool)
Add a single sample and update the internal state. returns true if the internal state was updated, also return the current value.
func (*SimpleExponentialMovingAverage) Get ¶ added in v0.1.6
func (m *SimpleExponentialMovingAverage) Get() float64
Get the current value.
func (*SimpleExponentialMovingAverage) Reset ¶ added in v0.1.6
func (m *SimpleExponentialMovingAverage) Reset()
Reset the internal state as if no samples were ever added.
func (*SimpleExponentialMovingAverage) Update ¶ added in v0.1.6
func (m *SimpleExponentialMovingAverage) Update(operation func(value float64) float64)
Update will update the value given an operation function
type SimpleMovingVariance ¶ added in v0.1.6
type SimpleMovingVariance struct {
// contains filtered or unexported fields
}
SimpleMovingVariance implements a simple moving variance calculation based on the simple moving average.
func NewSimpleMovingVariance ¶ added in v0.1.6
func NewSimpleMovingVariance( alphaAverage float64, alphaVariance float64, ) (*SimpleMovingVariance, error)
NewSimpleMovingVariance will create a new exponential moving variance approximation based on the SimpleMovingAverage
func (*SimpleMovingVariance) Add ¶ added in v0.1.6
func (m *SimpleMovingVariance) Add(value float64) (float64, bool)
Add a single sample and update the internal state. returns true if the internal state was updated, also return the current value.
func (*SimpleMovingVariance) Get ¶ added in v0.1.6
func (m *SimpleMovingVariance) Get() float64
Get the current value.
func (*SimpleMovingVariance) Reset ¶ added in v0.1.6
func (m *SimpleMovingVariance) Reset()
Reset the internal state as if no samples were ever added.
func (*SimpleMovingVariance) Update ¶ added in v0.1.6
func (m *SimpleMovingVariance) Update(operation func(value float64) float64)
Update will update the value given an operation function
type SingleMeasurement ¶
type SingleMeasurement struct {
// contains filtered or unexported fields
}
SingleMeasurement only keeps the latest value used.
func (*SingleMeasurement) Add ¶
func (m *SingleMeasurement) Add(value float64) (float64, bool)
Add a single sample and update the internal state.
func (*SingleMeasurement) Reset ¶
func (m *SingleMeasurement) Reset()
Reset the internal state as if no samples were ever added.
func (*SingleMeasurement) String ¶
func (m *SingleMeasurement) String() string
func (*SingleMeasurement) Update ¶
func (m *SingleMeasurement) Update(operation func(value float64) float64)
Update will update the value given an operation function
type WindowlessMovingPercentile ¶ added in v0.1.6
type WindowlessMovingPercentile struct {
// contains filtered or unexported fields
}
WindowlessMovingPercentile implements a moving percentile. This implementation uses a windowless calculation that while not strictly always accurate, provides a very close estimation in O(1) time and space. Much credit goes to Martin Jambon here: https://mjambon.com/2016-07-23-moving-percentile/ a copy can be found in github.com/platinummonkey/go-concurrency-limits/docs/assets/moving_percentile_reference.pdf and this is a port of the OCaml implementation provided in that reference.
func NewWindowlessMovingPercentile ¶ added in v0.1.6
func NewWindowlessMovingPercentile( p float64, deltaInitial float64, movingAvgAlphaAvg float64, movingVarianceAlphaVar float64, ) (*WindowlessMovingPercentile, error)
NewWindowlessMovingPercentile creates a new Windowless Moving Percentile p - percentile requested, accepts (0,1) deltaInitial - the initial delta value, here 0 is acceptable if you expect it to be rather stable at start, otherwise
choose a larger value. This would be estimated: `delta := stdev * r` where `r` is a user chosen constant. Good values are generally from 0.001 to 0.01
movingAvgAlphaAvg - this is the alpha value for the simple moving average. A good start is 0.05. Accepts [0,1] movingVarianceAlphaAvg - this is the alpha value for the simple moving variance. A good start is 0.05. Accepts [0,1]
func (*WindowlessMovingPercentile) Add ¶ added in v0.1.6
func (m *WindowlessMovingPercentile) Add(value float64) (float64, bool)
Add a single sample and update the internal state. returns true if the internal state was updated, also return the current value.
func (*WindowlessMovingPercentile) Get ¶ added in v0.1.6
func (m *WindowlessMovingPercentile) Get() float64
Get the current value.
func (*WindowlessMovingPercentile) Reset ¶ added in v0.1.6
func (m *WindowlessMovingPercentile) Reset()
Reset the internal state as if no samples were ever added.
func (*WindowlessMovingPercentile) Update ¶ added in v0.1.6
func (m *WindowlessMovingPercentile) Update(operation func(value float64) float64)
Update will update the value given an operation function