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)
| 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. |
| 1538 | func 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 | |
| 1588 | func BenchmarkBackendBlockQueryRange(b *testing.B) { |
| 1589 | testCases := []string{ |
nothing calls this directly
no test coverage detected