mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
metrics: minor improvements to runtimehistogram loop
This commit is contained in:
parent
8038c0fb01
commit
878680ee23
1 changed files with 14 additions and 18 deletions
|
|
@ -88,7 +88,6 @@ func (h *runtimeHistogramSnapshot) calc() {
|
|||
var (
|
||||
count int64 // number of samples
|
||||
sum float64 // approx sum of all sample values
|
||||
minSet = false
|
||||
min int64
|
||||
max float64
|
||||
)
|
||||
|
|
@ -96,17 +95,15 @@ func (h *runtimeHistogramSnapshot) calc() {
|
|||
return
|
||||
}
|
||||
for i, c := range h.internal.Counts {
|
||||
count += int64(c)
|
||||
midpoint := h.midpoint(i)
|
||||
sum += midpoint * float64(c)
|
||||
if c == 0 {
|
||||
continue
|
||||
}
|
||||
if !minSet {
|
||||
minSet = true
|
||||
if count == 0 { // Set min only first loop iteration
|
||||
min = int64(math.Floor(h.internal.Buckets[i]))
|
||||
}
|
||||
if count > 0 {
|
||||
count += int64(c)
|
||||
sum += h.midpoint(i) * float64(c)
|
||||
// Set max on every iteration
|
||||
edge := h.internal.Buckets[i+1]
|
||||
if math.IsInf(edge, 1) {
|
||||
edge = h.internal.Buckets[i]
|
||||
|
|
@ -115,7 +112,6 @@ func (h *runtimeHistogramSnapshot) calc() {
|
|||
max = edge
|
||||
}
|
||||
}
|
||||
}
|
||||
h.min = min
|
||||
h.max = int64(max)
|
||||
h.mean = sum / float64(count)
|
||||
|
|
|
|||
Loading…
Reference in a new issue