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

Function preparePartitionRingWithActivePartitions

ring/partition_ring_test.go:1162–1176  ·  view source on GitHub ↗
(partitions int)

Source from the content-addressed store, hash-verified

1160var cachedRings = map[int]*PartitionRing{}
1161
1162func preparePartitionRingWithActivePartitions(partitions int) *PartitionRing {
1163 pr := cachedRings[partitions]
1164 if pr != nil {
1165 return pr
1166 }
1167
1168 prd := NewPartitionRingDesc()
1169
1170 for pid := 0; pid < partitions; pid++ {
1171 prd.AddPartition(int32(pid), PartitionActive, time.Time{}) // benchmark doesn't use state or time.
1172 }
1173 pr, _ = NewPartitionRing(*prd)
1174 cachedRings[partitions] = pr
1175 return pr
1176}
1177
1178func BenchmarkPartitionRingGetTokenRangesForPartition(b *testing.B) {
1179 partitionsCount := []int{1, 3, 9, 27, 81, 243, 729}

Calls 3

AddPartitionMethod · 0.95
NewPartitionRingDescFunction · 0.85
NewPartitionRingFunction · 0.85

Tested by

no test coverage detected