tsdb: Tighten up sub-benchmark scope in BenchmarkQuerier (#12718)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
eeead61e48
commit
de7e057d3c
|
@ -31,10 +31,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkQuerier(b *testing.B) {
|
func BenchmarkQuerier(b *testing.B) {
|
||||||
chunkDir := b.TempDir()
|
|
||||||
opts := DefaultHeadOptions()
|
opts := DefaultHeadOptions()
|
||||||
opts.ChunkRange = 1000
|
opts.ChunkRange = 1000
|
||||||
opts.ChunkDirRoot = chunkDir
|
opts.ChunkDirRoot = b.TempDir()
|
||||||
h, err := NewHead(nil, nil, nil, nil, opts, nil)
|
h, err := NewHead(nil, nil, nil, nil, opts, nil)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -58,9 +57,13 @@ func BenchmarkQuerier(b *testing.B) {
|
||||||
}
|
}
|
||||||
require.NoError(b, app.Commit())
|
require.NoError(b, app.Commit())
|
||||||
|
|
||||||
|
b.Run("Head", func(b *testing.B) {
|
||||||
ir, err := h.Index()
|
ir, err := h.Index()
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
b.Run("Head", func(b *testing.B) {
|
defer func() {
|
||||||
|
require.NoError(b, ir.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
b.Run("PostingsForMatchers", func(b *testing.B) {
|
b.Run("PostingsForMatchers", func(b *testing.B) {
|
||||||
benchmarkPostingsForMatchers(b, ir)
|
benchmarkPostingsForMatchers(b, ir)
|
||||||
})
|
})
|
||||||
|
@ -69,18 +72,20 @@ func BenchmarkQuerier(b *testing.B) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
tmpdir := b.TempDir()
|
b.Run("Block", func(b *testing.B) {
|
||||||
|
blockdir := createBlockFromHead(b, b.TempDir(), h)
|
||||||
blockdir := createBlockFromHead(b, tmpdir, h)
|
|
||||||
block, err := OpenBlock(nil, blockdir, nil)
|
block, err := OpenBlock(nil, blockdir, nil)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
require.NoError(b, block.Close())
|
require.NoError(b, block.Close())
|
||||||
}()
|
}()
|
||||||
ir, err = block.Index()
|
|
||||||
|
ir, err := block.Index()
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
defer ir.Close()
|
defer func() {
|
||||||
b.Run("Block", func(b *testing.B) {
|
require.NoError(b, ir.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
b.Run("PostingsForMatchers", func(b *testing.B) {
|
b.Run("PostingsForMatchers", func(b *testing.B) {
|
||||||
benchmarkPostingsForMatchers(b, ir)
|
benchmarkPostingsForMatchers(b, ir)
|
||||||
})
|
})
|
||||||
|
@ -239,10 +244,9 @@ func BenchmarkMergedStringIter(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkQuerierSelect(b *testing.B) {
|
func BenchmarkQuerierSelect(b *testing.B) {
|
||||||
chunkDir := b.TempDir()
|
|
||||||
opts := DefaultHeadOptions()
|
opts := DefaultHeadOptions()
|
||||||
opts.ChunkRange = 1000
|
opts.ChunkRange = 1000
|
||||||
opts.ChunkDirRoot = chunkDir
|
opts.ChunkDirRoot = b.TempDir()
|
||||||
h, err := NewHead(nil, nil, nil, nil, opts, nil)
|
h, err := NewHead(nil, nil, nil, nil, opts, nil)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
defer h.Close()
|
defer h.Close()
|
||||||
|
|
Loading…
Reference in New Issue