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 {
|
||||
continue
|
||||
}
|
||||
|
||||
if c > 0 && !minSet {
|
||||
if !minSet {
|
||||
minSet = true
|
||||
min = int64(math.Floor(h.internal.Buckets[i]))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,10 +187,11 @@ type sampleSnapshot struct {
|
|||
count int64
|
||||
values []int64
|
||||
|
||||
max int64
|
||||
min int64
|
||||
mean float64
|
||||
sum int64
|
||||
max int64
|
||||
min int64
|
||||
mean float64
|
||||
sum int64
|
||||
variance float64
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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.
|
||||
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.
|
||||
func (s *sampleSnapshot) Variance() float64 { return SampleVariance(s.mean, s.values) }
|
||||
|
||||
// SampleStdDev returns the standard deviation of the slice of int64.
|
||||
func SampleStdDev(mean float64, values []int64) float64 {
|
||||
return math.Sqrt(SampleVariance(mean, values))
|
||||
func (s *sampleSnapshot) Variance() float64 {
|
||||
if s.variance == 0.0 {
|
||||
s.variance = SampleVariance(s.mean, s.values)
|
||||
}
|
||||
return s.variance
|
||||
}
|
||||
|
||||
// SampleVariance returns the variance of the slice of int64.
|
||||
|
|
|
|||
Loading…
Reference in a new issue