Benchmark tests
(b *testing.B)
| 375 | |
| 376 | // Benchmark tests |
| 377 | func BenchmarkWantConnQueue_Enqueue(b *testing.B) { |
| 378 | q := newWantConnQueue() |
| 379 | |
| 380 | // Pre-allocate a pool of wantConn to reuse |
| 381 | const poolSize = 1000 |
| 382 | wantConnPool := make([]*wantConn, poolSize) |
| 383 | for i := 0; i < poolSize; i++ { |
| 384 | wantConnPool[i] = &wantConn{ |
| 385 | ctx: context.Background(), |
| 386 | result: make(chan wantConnResult, 1), |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | b.ResetTimer() |
| 391 | |
| 392 | for i := 0; i < b.N; i++ { |
| 393 | w := wantConnPool[i%poolSize] |
| 394 | q.enqueue(w) |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | func BenchmarkWantConnQueue_Dequeue(b *testing.B) { |
| 399 | q := newWantConnQueue() |
nothing calls this directly
no test coverage detected