MCPcopy
hub / github.com/grafana/tempo / BenchmarkSearch

Function BenchmarkSearch

tempodb/wal/wal_test.go:470–501  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

468}
469
470func 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
503func runWALBenchmark(b *testing.B, encoding string, flushCount int, runner func([][]byte, []*tempopb.Trace, common.WALBlock)) {
504 runWALBenchmarkWithAppendMode(b, encoding, flushCount, false, runner)

Callers

nothing calls this directly

Calls 9

AllEncodingsForWritesFunction · 0.92
DefaultSearchOptionsFunction · 0.92
TraceIDToHexStringFunction · 0.92
runWALBenchmarkFunction · 0.85
findFirstAttributeFunction · 0.85
VersionMethod · 0.65
SearchMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected