Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment the zero bucket using the increment multiplier #238

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (h *Histogram[N]) UpdateByIncr(number N, incr uint64) {
h.count += incr

if value == 0 {
h.zeroCount++
h.zeroCount += incr
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ func TestAggregatorCopySwap(t *testing.T) {
requireEqual(t, h2, h3)
}

// TestZeroCountByIncr verifies that zero counts are incremented properly.
func TestZeroCountByIncr(t *testing.T) {
// 10 "0" values
h1 := NewFloat64(NewConfig(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
h2 := NewFloat64(NewConfig())
h2.UpdateByIncr(0, 10)

requireEqual(t, h1, h2)
}

// Benchmarks the Update() function for values in the range [1,2)
func BenchmarkLinear(b *testing.B) {
src := rand.NewSource(77777677777)
Expand Down