MCPcopy Index your code
hub / github.com/cortexproject/cortex / BenchmarkRing_Get

Function BenchmarkRing_Get

pkg/ring/ring_test.go:2822–2853  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

2820}
2821
2822func BenchmarkRing_Get(b *testing.B) {
2823 const (
2824 numInstances = 100
2825 numZones = 3
2826 replicationFactor = 3
2827 )
2828
2829 // Initialise the ring.
2830 ringDesc := &Desc{Ingesters: generateRingInstances(numInstances, numZones, numTokens)}
2831 ring := Ring{
2832 cfg: Config{HeartbeatTimeout: time.Hour, ZoneAwarenessEnabled: true, SubringCacheDisabled: true, ReplicationFactor: replicationFactor},
2833 ringDesc: ringDesc,
2834 ringTokens: ringDesc.GetTokens(),
2835 ringTokensByZone: ringDesc.getTokensByZone(),
2836 ringInstanceByToken: ringDesc.getTokensInfo(),
2837 ringZones: getZones(ringDesc.getTokensByZone()),
2838 shuffledSubringCache: map[subringCacheKey]*Ring{},
2839 strategy: NewDefaultReplicationStrategy(),
2840 lastTopologyChange: time.Now(),
2841 KVClient: &MockClient{},
2842 }
2843
2844 buf, bufHosts, bufZones := MakeBuffersForGet()
2845 r := rand.New(rand.NewSource(time.Now().UnixNano()))
2846
2847 for b.Loop() {
2848 set, err := ring.Get(r.Uint32(), Write, buf, bufHosts, bufZones)
2849 if err != nil || len(set.Instances) != replicationFactor {
2850 b.Fatal()
2851 }
2852 }
2853}
2854
2855func TestRing_Get_NoMemoryAllocations(t *testing.T) {
2856 // Initialise the ring.

Callers

nothing calls this directly

Calls 9

GetTokensMethod · 0.95
getTokensByZoneMethod · 0.95
getTokensInfoMethod · 0.95
GetMethod · 0.95
generateRingInstancesFunction · 0.85
getZonesFunction · 0.85
MakeBuffersForGetFunction · 0.85
LoopMethod · 0.80

Tested by

no test coverage detected