Skip to content

Commit

Permalink
Labels: add BenchmarkScratchBuilder_Equal
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed Jun 5, 2024
1 parent 50fc867 commit 1b0c990
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions model/labels/labels_dedupelabels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,18 @@ func TestVarint(t *testing.T) {
}
require.Panics(t, func() { encodeVarint(buf[:], len(buf), 1<<29) })
}

func BenchmarkScratchBuilder_Equal(b *testing.B) {
for _, scenario := range comparisonBenchmarkScenarios {
builder := NewScratchBuilder(scenario.base.Len())
scenario.base.Range(func(l Label) {
builder.Add(l.Name, l.Value)
})
b.Run(scenario.desc, func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = builder.Equal(scenario.other)
}
})
}
}

0 comments on commit 1b0c990

Please sign in to comment.