mirror of
https://github.com/owncast/owncast.git
synced 2025-11-03 04:27:18 +08:00
Tame down encoding performance alerts. Closes #338
This commit is contained in:
@ -13,8 +13,8 @@ var _durationStorage = make(map[string][]float64)
|
||||
|
||||
// StartPerformanceMonitor will keep track of the start time of this event.
|
||||
func StartPerformanceMonitor(key string) {
|
||||
if len(_durationStorage[key]) > 30 {
|
||||
_durationStorage[key] = removeHighAndLow(_durationStorage[key])
|
||||
if len(_durationStorage[key]) > 20 {
|
||||
_durationStorage[key] = removeHighValue(_durationStorage[key])
|
||||
}
|
||||
_pointsInTime[key] = time.Now()
|
||||
}
|
||||
@ -28,16 +28,16 @@ func GetAveragePerformance(key string) float64 {
|
||||
|
||||
delta := time.Since(timestamp).Seconds()
|
||||
_durationStorage[key] = append(_durationStorage[key], delta)
|
||||
if len(_durationStorage[key]) < 10 {
|
||||
if len(_durationStorage[key]) < 8 {
|
||||
return 0
|
||||
}
|
||||
_durationStorage[key] = removeHighAndLow(_durationStorage[key])
|
||||
_durationStorage[key] = removeHighValue(_durationStorage[key])
|
||||
return avg(_durationStorage[key])
|
||||
}
|
||||
|
||||
func removeHighAndLow(values []float64) []float64 {
|
||||
func removeHighValue(values []float64) []float64 {
|
||||
sort.Float64s(values)
|
||||
return values[1 : len(values)-1]
|
||||
return values[:len(values)-1]
|
||||
}
|
||||
|
||||
func avg(values []float64) float64 {
|
||||
|
||||
Reference in New Issue
Block a user