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

Function BenchmarkIterators

tempodb/encoding/vparquet5/block_traceql_test.go:1723–1784  ·  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

1721// BenchmarkIterators is a convenient method to run benchmarks on various iterator constructions directly when working on optimizations.
1722// Replace the iterator at the beginning of the benchmark loop with any combination desired.
1723func BenchmarkIterators(b *testing.B) {
1724 ctx := context.TODO()
1725 opts := common.DefaultSearchOptions()
1726 opts.StartPage = 3
1727 opts.TotalPages = 2
1728
1729 block := blockForBenchmarks(b)
1730 pf, _, err := block.openForSearch(ctx, opts)
1731 require.NoError(b, err)
1732
1733 rgs := pf.RowGroups()
1734 rgs = rgs[3:5]
1735
1736 var instrPred *pq.InstrumentedPredicate
1737 makeIterInternal := makeIterFunc(ctx, rgs, pf)
1738 makeIter := func(columnName string, predicate pq.Predicate, selectAs string) pq.Iterator {
1739 instrPred = &pq.InstrumentedPredicate{
1740 Pred: predicate,
1741 }
1742
1743 return makeIterInternal(columnName, predicate, selectAs)
1744 }
1745
1746 b.ResetTimer()
1747 for i := 0; i < b.N; i++ {
1748 err := error(nil)
1749
1750 iter := makeIter(columnPathSpanAttrKey, pq.NewSubstringPredicate("e"), "foo")
1751
1752 // parquetquery.NewUnionIterator(DefinitionLevelResourceSpansILSSpanAttrs, []parquetquery.Iterator{
1753 // makeIter(columnPathSpanHTTPStatusCode, parquetquery.NewIntEqualPredicate(500), "http_status"),
1754 // makeIter(columnPathSpanName, parquetquery.NewStringEqualPredicate([]byte("foo")), "name"),
1755 // makeIter(columnPathSpanStatusCode, parquetquery.NewIntEqualPredicate(2), "status"),
1756 // makeIter(columnPathSpanAttrDouble, parquetquery.NewFloatEqualPredicate(500), "double"),
1757 // makeIter(columnPathSpanAttrInt, parquetquery.NewIntEqualPredicate(500), "int"),
1758 // }, nil)
1759 require.NoError(b, err)
1760 // fmt.Println(iter.String())
1761
1762 count := 0
1763 for {
1764 res, err := iter.Next()
1765 if err != nil {
1766 panic(err)
1767 }
1768 if res == nil {
1769 break
1770 }
1771 count++
1772 }
1773 iter.Close()
1774 if instrPred != nil {
1775 b.ReportMetric(float64(count), "count")
1776 b.ReportMetric(float64(instrPred.InspectedColumnChunks), "stats_cc")
1777 b.ReportMetric(float64(instrPred.KeptColumnChunks), "stats_cc_kept")
1778 b.ReportMetric(float64(instrPred.InspectedPages), "stats_ip")
1779 b.ReportMetric(float64(instrPred.KeptPages), "stats_ip_kept")
1780 b.ReportMetric(float64(instrPred.InspectedValues), "stats_v")

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected