mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
metrics: cache sample variance, rm ineffectual clause rthistogram
This commit is contained in:
parent
267656019b
commit
8038c0fb01
2 changed files with 17 additions and 12 deletions
|
|
@ -102,8 +102,7 @@ func (h *runtimeHistogramSnapshot) calc() {
|
||||||
if c == 0 {
|
if c == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if !minSet {
|
||||||
if c > 0 && !minSet {
|
|
||||||
minSet = true
|
minSet = true
|
||||||
min = int64(math.Floor(h.internal.Buckets[i]))
|
min = int64(math.Floor(h.internal.Buckets[i]))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,10 +187,11 @@ type sampleSnapshot struct {
|
||||||
count int64
|
count int64
|
||||||
values []int64
|
values []int64
|
||||||
|
|
||||||
max int64
|
max int64
|
||||||
min int64
|
min int64
|
||||||
mean float64
|
mean float64
|
||||||
sum int64
|
sum int64
|
||||||
|
variance float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// newSampleSnapshotPrecalculated creates a read-only sampleSnapShot, using
|
// newSampleSnapshotPrecalculated creates a read-only sampleSnapShot, using
|
||||||
|
|
@ -265,7 +266,12 @@ func (s *sampleSnapshot) Snapshot() SampleSnapshot { return s }
|
||||||
|
|
||||||
// StdDev returns the standard deviation of values at the time the snapshot was
|
// StdDev returns the standard deviation of values at the time the snapshot was
|
||||||
// taken.
|
// taken.
|
||||||
func (s *sampleSnapshot) StdDev() float64 { return SampleStdDev(s.mean, s.values) }
|
func (s *sampleSnapshot) StdDev() float64 {
|
||||||
|
if s.variance == 0.0 {
|
||||||
|
s.variance = SampleVariance(s.mean, s.values)
|
||||||
|
}
|
||||||
|
return math.Sqrt(s.variance)
|
||||||
|
}
|
||||||
|
|
||||||
// Sum returns the sum of values at the time the snapshot was taken.
|
// Sum returns the sum of values at the time the snapshot was taken.
|
||||||
func (s *sampleSnapshot) Sum() int64 { return s.sum }
|
func (s *sampleSnapshot) Sum() int64 { return s.sum }
|
||||||
|
|
@ -278,11 +284,11 @@ func (s *sampleSnapshot) Values() []int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variance returns the variance of values at the time the snapshot was taken.
|
// Variance returns the variance of values at the time the snapshot was taken.
|
||||||
func (s *sampleSnapshot) Variance() float64 { return SampleVariance(s.mean, s.values) }
|
func (s *sampleSnapshot) Variance() float64 {
|
||||||
|
if s.variance == 0.0 {
|
||||||
// SampleStdDev returns the standard deviation of the slice of int64.
|
s.variance = SampleVariance(s.mean, s.values)
|
||||||
func SampleStdDev(mean float64, values []int64) float64 {
|
}
|
||||||
return math.Sqrt(SampleVariance(mean, values))
|
return s.variance
|
||||||
}
|
}
|
||||||
|
|
||||||
// SampleVariance returns the variance of the slice of int64.
|
// SampleVariance returns the variance of the slice of int64.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue