diff options
| author | Will Hawkins <[email protected]> | 2022-11-20 00:10:15 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2022-11-20 02:39:09 -0500 |
| commit | 5e0e8ba0be2c98b5f54e55fdbc1b928a4717e047 (patch) | |
| tree | b3816fde96d0a8077e1034d898d0fbd8b8e7ebbc /stabilizer/rev3.go | |
| parent | 10a52af363b0d52d78af0158cbaa404a1ce35b82 (diff) | |
[Feature] Make MathematicalSeries an interface
1. Make MathematicalSeries an interface so that there
can be different ways for implementing it.
2. Introduce a CappedMathematicalSeries that stores a
maximum of N recent (by time of insertion) values.
3. Add a method to the MathematicalSeries interface
for calculating the Nth percentile of the values it
contains.
Diffstat (limited to 'stabilizer/rev3.go')
| -rw-r--r-- | stabilizer/rev3.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/stabilizer/rev3.go b/stabilizer/rev3.go index 2e29626..79f5f27 100644 --- a/stabilizer/rev3.go +++ b/stabilizer/rev3.go @@ -11,8 +11,8 @@ import ( ) type DataPointStabilizer struct { - instantaneousMeasurements *ms.MathematicalSeries[float64] - movingAverages *ms.MathematicalSeries[float64] + instantaneousMeasurements ms.MathematicalSeries[float64] + movingAverages ms.MathematicalSeries[float64] stabilityStandardDeviation float64 m sync.Mutex dbgLevel debug.DebugLevel @@ -30,8 +30,8 @@ type ThroughputStabilizer DataPointStabilizer // moving averages of a measurement. func NewProbeStabilizer(i int, k int, s float64, debugLevel debug.DebugLevel, debug *debug.DebugWithPrefix) ProbeStabilizer { - return ProbeStabilizer{instantaneousMeasurements: ms.NewMathematicalSeries[float64](i), - movingAverages: ms.NewMathematicalSeries[float64](k), + return ProbeStabilizer{instantaneousMeasurements: ms.NewCappedMathematicalSeries[float64](i), + movingAverages: ms.NewCappedMathematicalSeries[float64](k), stabilityStandardDeviation: s, dbgConfig: debug, dbgLevel: debugLevel} @@ -97,8 +97,8 @@ func (r3 *ProbeStabilizer) IsStable() bool { } func NewThroughputStabilizer(i int, k int, s float64, debugLevel debug.DebugLevel, debug *debug.DebugWithPrefix) ThroughputStabilizer { - return ThroughputStabilizer{instantaneousMeasurements: ms.NewMathematicalSeries[float64](i), - movingAverages: ms.NewMathematicalSeries[float64](k), + return ThroughputStabilizer{instantaneousMeasurements: ms.NewCappedMathematicalSeries[float64](i), + movingAverages: ms.NewCappedMathematicalSeries[float64](k), stabilityStandardDeviation: s, dbgConfig: debug, dbgLevel: debugLevel} |
