(b *testing.B)
| 73 | } |
| 74 | |
| 75 | func 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 | |
| 116 | func BenchmarkGetNextRequestPriorityQueue(b *testing.B) { |
| 117 | const maxOutstandingPerTenant = 2 |
nothing calls this directly
no test coverage detected