(b *testing.B)
| 468 | } |
| 469 | |
| 470 | func BenchmarkSearch(b *testing.B) { |
| 471 | for _, enc := range encoding.AllEncodingsForWrites() { |
| 472 | version := enc.Version() |
| 473 | b.Run(version, func(b *testing.B) { |
| 474 | runWALBenchmark(b, version, 1, func(ids [][]byte, objs []*tempopb.Trace, block common.WALBlock) { |
| 475 | ctx := context.Background() |
| 476 | |
| 477 | for i := 0; i < b.N; i++ { |
| 478 | j := i % len(ids) |
| 479 | id, o := ids[j], objs[j] |
| 480 | |
| 481 | k, v := findFirstAttribute(o) |
| 482 | require.NotEmpty(b, k) |
| 483 | require.NotEmpty(b, v) |
| 484 | |
| 485 | resp, err := block.Search(ctx, &tempopb.SearchRequest{ |
| 486 | Tags: map[string]string{ |
| 487 | k: v, |
| 488 | }, |
| 489 | Limit: 10, |
| 490 | }, common.DefaultSearchOptions()) |
| 491 | if errors.Is(err, util.ErrUnsupported) { |
| 492 | return |
| 493 | } |
| 494 | require.NoError(b, err) |
| 495 | require.Equal(b, 1, len(resp.Traces)) |
| 496 | require.Equal(b, util.TraceIDToHexString(id), resp.Traces[0].TraceID) |
| 497 | } |
| 498 | }) |
| 499 | }) |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | func runWALBenchmark(b *testing.B, encoding string, flushCount int, runner func([][]byte, []*tempopb.Trace, common.WALBlock)) { |
| 504 | runWALBenchmarkWithAppendMode(b, encoding, flushCount, false, runner) |
nothing calls this directly
no test coverage detected