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

Function BenchmarkIterators

tempodb/encoding/vparquet4/block_traceql_test.go:1538–1586  ·  view source on GitHub ↗

BenchmarkIterators is a convenient method to run benchmarks on various iterator constructions directly when working on optimizations. Replace the iterator at the beginning of the benchmark loop with any combination desired.

(b *testing.B)

Source from the content-addressed store, hash-verified

1536// BenchmarkIterators is a convenient method to run benchmarks on various iterator constructions directly when working on optimizations.
1537// Replace the iterator at the beginning of the benchmark loop with any combination desired.
1538func BenchmarkIterators(b *testing.B) {
1539 ctx := context.TODO()
1540 opts := common.DefaultSearchOptions()
1541 opts.StartPage = 3
1542 opts.TotalPages = 2
1543
1544 block := blockForBenchmarks(b)
1545 pf, _, err := block.openForSearch(ctx, opts)
1546 require.NoError(b, err)
1547
1548 rgs := pf.RowGroups()
1549 rgs = rgs[3:5]
1550
1551 var instrPred *parquetquery.InstrumentedPredicate
1552 makeIterInternal := makeIterFunc(ctx, rgs, pf)
1553 makeIter := func(columnName string, predicate parquetquery.Predicate, selectAs string) parquetquery.Iterator {
1554 instrPred = &parquetquery.InstrumentedPredicate{
1555 Pred: predicate,
1556 }
1557
1558 return makeIterInternal(columnName, predicate, selectAs)
1559 }
1560
1561 b.ResetTimer()
1562 for i := 0; i < b.N; i++ {
1563 iter := makeIter(columnPathSpanAttrKey, parquetquery.NewSubstringPredicate("e"), "foo")
1564 count := 0
1565 for {
1566 res, err := iter.Next()
1567 if err != nil {
1568 panic(err)
1569 }
1570 if res == nil {
1571 break
1572 }
1573 count++
1574 }
1575 iter.Close()
1576 if instrPred != nil {
1577 b.ReportMetric(float64(count), "count")
1578 b.ReportMetric(float64(instrPred.InspectedColumnChunks), "stats_cc")
1579 b.ReportMetric(float64(instrPred.KeptColumnChunks), "stats_cc_kept")
1580 b.ReportMetric(float64(instrPred.InspectedPages), "stats_ip")
1581 b.ReportMetric(float64(instrPred.KeptPages), "stats_ip_kept")
1582 b.ReportMetric(float64(instrPred.InspectedValues), "stats_v")
1583 b.ReportMetric(float64(instrPred.KeptValues), "stats_v_kept")
1584 }
1585 }
1586}
1587
1588func BenchmarkBackendBlockQueryRange(b *testing.B) {
1589 testCases := []string{

Callers

nothing calls this directly

Calls 7

DefaultSearchOptionsFunction · 0.92
NewSubstringPredicateFunction · 0.92
blockForBenchmarksFunction · 0.70
makeIterFuncFunction · 0.70
NextMethod · 0.65
CloseMethod · 0.65
openForSearchMethod · 0.45

Tested by

no test coverage detected