mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Simplify benchmark given the new API
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
parent
38d32e0686
commit
61262159c4
|
@ -18,8 +18,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
|
@ -136,30 +136,21 @@ func BenchmarkQuerierSelect(b *testing.B) {
|
||||||
}
|
}
|
||||||
testutil.Ok(b, app.Commit())
|
testutil.Ok(b, app.Commit())
|
||||||
|
|
||||||
emptyHead, err := NewHead(nil, nil, nil, 1000)
|
bench := func(b *testing.B, br BlockReader, sorted bool) {
|
||||||
testutil.Ok(b, err)
|
|
||||||
defer emptyHead.Close()
|
|
||||||
|
|
||||||
bench := func(b *testing.B, br BlockReader, multiBlock bool) {
|
|
||||||
matcher := labels.MustNewMatcher(labels.MatchEqual, "foo", "bar")
|
matcher := labels.MustNewMatcher(labels.MatchEqual, "foo", "bar")
|
||||||
for s := 1; s <= numSeries; s *= 10 {
|
for s := 1; s <= numSeries; s *= 10 {
|
||||||
b.Run(fmt.Sprintf("%dof%d", s, numSeries), func(b *testing.B) {
|
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)
|
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()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
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)
|
testutil.Ok(b, err)
|
||||||
for ss.Next() {
|
for ss.Next() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue