Extend BenchmarkQuerierSelect to use multiple blocks.
@@ -136,12 +136,26 @@ func BenchmarkQuerierSelect(b *testing.B) {
}
testutil.Ok(b, app.Commit())
- bench := func(b *testing.B, br BlockReader) {
+ emptyHead, err := NewHead(nil, nil, nil, 1000)
+ testutil.Ok(b, err)
+ defer emptyHead.Close()
+
+ bench := func(b *testing.B, br BlockReader, multiBlock bool) {
matcher := labels.MustNewMatcher(labels.MatchEqual, "foo", "bar")
for s := 1; s <= numSeries; s *= 10 {
b.Run(fmt.Sprintf("%dof%d", s, numSeries), func(b *testing.B) {
- q, err := NewBlockQuerier(br, 0, int64(s-1))
+ bq, err := NewBlockQuerier(br, 0, int64(s-1))
+ testutil.Ok(b, err)
+ blocks := []Querier{bq}
+
+ if multiBlock {
+ // Passing more than one block to the querier will trigger
+ // sorting of the returned series.
+ bq, err := NewBlockQuerier(emptyHead, 0, int64(s-1))
testutil.Ok(b, err)
+ blocks = append(blocks, bq)
+ }
+ q := &querier{blocks: blocks}
b.ResetTimer()
for i := 0; i < b.N; i++ {
@@ -157,7 +171,10 @@ func BenchmarkQuerierSelect(b *testing.B) {
}
b.Run("Head", func(b *testing.B) {
- bench(b, h)
+ bench(b, h, false)
+ })
+ b.Run("SortedHead", func(b *testing.B) {
+ bench(b, h, true)
})
tmpdir, err := ioutil.TempDir("", "test_benchquerierselect")
@@ -174,6 +191,6 @@ func BenchmarkQuerierSelect(b *testing.B) {
}()
b.Run("Block", func(b *testing.B) {
- bench(b, block)
+ bench(b, block, false)
})
}
