(b *testing.B)
| 2820 | } |
| 2821 | |
| 2822 | func 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 | |
| 2855 | func TestRing_Get_NoMemoryAllocations(t *testing.T) { |
| 2856 | // Initialise the ring. |
nothing calls this directly
no test coverage detected