(b *testing.B)
| 351 | } |
| 352 | |
| 353 | func BenchmarkMemcachedClient_sortKeysByServer(b *testing.B) { |
| 354 | mockSelector := &mockServerSelector{ |
| 355 | servers: []mockServer{ |
| 356 | {addr: "127.0.0.1"}, |
| 357 | {addr: "127.0.0.2"}, |
| 358 | {addr: "127.0.0.3"}, |
| 359 | {addr: "127.0.0.4"}, |
| 360 | {addr: "127.0.0.5"}, |
| 361 | {addr: "127.0.0.6"}, |
| 362 | {addr: "127.0.0.7"}, |
| 363 | {addr: "127.0.0.8"}, |
| 364 | }, |
| 365 | } |
| 366 | |
| 367 | client, err := newMemcachedClient( |
| 368 | log.NewNopLogger(), |
| 369 | newMockMemcachedClientBackend(), |
| 370 | mockSelector, |
| 371 | MemcachedClientConfig{ |
| 372 | Addresses: []string{"localhost"}, |
| 373 | MaxAsyncConcurrency: 1, |
| 374 | MaxAsyncBufferSize: 10, |
| 375 | }, |
| 376 | prometheus.NewPedanticRegistry(), |
| 377 | "test", |
| 378 | ) |
| 379 | |
| 380 | if err != nil { |
| 381 | b.Fatal("unexpected error creating MemcachedClient", err) |
| 382 | } |
| 383 | |
| 384 | const numKeys = 10_000 |
| 385 | |
| 386 | keys := make([]string, numKeys) |
| 387 | for i := 0; i < numKeys; i++ { |
| 388 | keys[i] = fmt.Sprintf("some-key:%d", i) |
| 389 | } |
| 390 | |
| 391 | b.ResetTimer() |
| 392 | for i := 0; i < b.N; i++ { |
| 393 | client.sortKeysByServer(keys) |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | func setupDefaultMemcachedClient() (*MemcachedClient, *mockMemcachedClientBackend, error) { |
| 398 | backend := newMockMemcachedClientBackend() |
nothing calls this directly
no test coverage detected