Simplify benchmark given the new API

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
Brian Brazil 2020-01-17 11:41:31 +00:00
parent 38d32e0686
commit 61262159c4
2 changed files with 9 additions and 18 deletions

View File

@ -18,8 +18,8 @@ import (
"errors"
"io/ioutil"
"os"
"strings"
"sort"
"strings"
"testing"
"time"

View File

@ -136,30 +136,21 @@ func BenchmarkQuerierSelect(b *testing.B) {
}
testutil.Ok(b, app.Commit())
emptyHead, err := NewHead(nil, nil, nil, 1000)
testutil.Ok(b, err)
defer emptyHead.Close()
bench := func(b *testing.B, br BlockReader, multiBlock bool) {
bench := func(b *testing.B, br BlockReader, sorted 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) {
bq, err := NewBlockQuerier(br, 0, int64(s-1))
q, 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++ {
ss, err := q.Select(matcher)
var ss SeriesSet
if sorted {
ss, err = q.SelectSorted(matcher)
} else {
ss, err = q.Select(matcher)
}
testutil.Ok(b, err)
for ss.Next() {
}