MCPcopy Create free account
hub / github.com/cortexproject/cortex / BenchmarkQueueRequest

Function BenchmarkQueueRequest

pkg/scheduler/queue/queue_test.go:75–114  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

73}
74
75func BenchmarkQueueRequest(b *testing.B) {
76 const maxOutstandingPerTenant = 2
77 const numTenants = 50
78 const queriers = 5
79
80 queues := make([]*RequestQueue, 0, b.N)
81 users := make([]string, 0, numTenants)
82 requests := make([]MockRequest, 0, numTenants)
83
84 for n := 0; b.Loop(); n++ {
85 q := NewRequestQueue(maxOutstandingPerTenant,
86 prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user", "priority", "type"}),
87 prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user", "priority"}),
88 MockLimits{MaxOutstanding: 100},
89 nil,
90 )
91
92 for ix := range queriers {
93 q.RegisterQuerierConnection(fmt.Sprintf("querier-%d", ix))
94 }
95
96 queues = append(queues, q)
97
98 for j := range numTenants {
99 requests = append(requests, MockRequest{id: fmt.Sprintf("%d-%d", n, j)})
100 users = append(users, strconv.Itoa(j))
101 }
102 }
103
104 for n := 0; b.Loop(); n++ {
105 for range maxOutstandingPerTenant {
106 for j := range numTenants {
107 err := queues[n].EnqueueRequest(users[j], requests[j], 0, nil)
108 if err != nil {
109 b.Fatal(err)
110 }
111 }
112 }
113 }
114}
115
116func BenchmarkGetNextRequestPriorityQueue(b *testing.B) {
117 const maxOutstandingPerTenant = 2

Callers

nothing calls this directly

Calls 4

NewRequestQueueFunction · 0.85
LoopMethod · 0.80
EnqueueRequestMethod · 0.80

Tested by

no test coverage detected