MCPcopy
hub / github.com/grafana/dskit / BenchmarkPartitionRing_ActivePartitionForKey

Function BenchmarkPartitionRing_ActivePartitionForKey

ring/partition_ring_test.go:155–172  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

153}
154
155func BenchmarkPartitionRing_ActivePartitionForKey(b *testing.B) {
156 const (
157 numActivePartitions = 100
158 numInactivePartitions = 10
159 )
160
161 ring := createPartitionRingWithPartitions(DefaultPartitionRingOptions(), numActivePartitions, numInactivePartitions, 0)
162 r := rand.New(rand.NewSource(time.Now().UnixNano()))
163
164 b.ResetTimer()
165
166 for n := 0; n < b.N; n++ {
167 _, err := ring.ActivePartitionForKey(r.Uint32())
168 if err != nil {
169 b.Fail()
170 }
171 }
172}
173
174func TestPartitionRing_ShuffleShard(t *testing.T) {
175 t.Run("should honor the shard size", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

ActivePartitionForKeyMethod · 0.80
FailMethod · 0.80

Tested by

no test coverage detected