mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
metrics/librato: fix incorrect calculation of sumSquares
This commit is contained in:
parent
acd1eaae2c
commit
a42f42aa06
1 changed files with 2 additions and 10 deletions
|
|
@ -62,22 +62,14 @@ func (rep *Reporter) Run() {
|
||||||
// calculate sum of squares from data provided by metrics.Histogram
|
// calculate sum of squares from data provided by metrics.Histogram
|
||||||
// see http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
|
// see http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
|
||||||
func sumSquares(icount int64, mean, stDev float64) float64 {
|
func sumSquares(icount int64, mean, stDev float64) float64 {
|
||||||
count := float64(icount)
|
sumSquares := float64(icount) * (math.Pow(mean, 2) + math.Pow(stDev, 2))
|
||||||
sumSquared := math.Pow(count*mean, 2)
|
|
||||||
sumSquares := math.Pow(count*stDev, 2) + sumSquared/count
|
|
||||||
if math.IsNaN(sumSquares) {
|
if math.IsNaN(sumSquares) {
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
return sumSquares
|
return sumSquares
|
||||||
}
|
}
|
||||||
func sumSquaresTimer(t metrics.TimerSnapshot) float64 {
|
func sumSquaresTimer(t metrics.TimerSnapshot) float64 {
|
||||||
count := float64(t.Count())
|
return sumSquares(t.Count(), t.Mean(), t.StdDev())
|
||||||
sumSquared := math.Pow(count*t.Mean(), 2)
|
|
||||||
sumSquares := math.Pow(count*t.StdDev(), 2) + sumSquared/count
|
|
||||||
if math.IsNaN(sumSquares) {
|
|
||||||
return 0.0
|
|
||||||
}
|
|
||||||
return sumSquares
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rep *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
|
func (rep *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue