MCPcopy Create free account
hub / github.com/cortexproject/cortex / BenchmarkNewChunkMergeIterator_Seek

Function BenchmarkNewChunkMergeIterator_Seek

pkg/querier/batch/batch_test.go:73–120  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

71}
72
73func BenchmarkNewChunkMergeIterator_Seek(b *testing.B) {
74 scenarios := []struct {
75 numChunks int
76 numSamplesPerChunk int
77 duplicationFactor int
78 seekStep time.Duration
79 scrapeInterval time.Duration
80 enc promchunk.Encoding
81 }{
82 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second / 2, enc: promchunk.PrometheusXorChunk},
83 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second, enc: promchunk.PrometheusXorChunk},
84 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 2, enc: promchunk.PrometheusXorChunk},
85 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 10, enc: promchunk.PrometheusXorChunk},
86 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 30, enc: promchunk.PrometheusXorChunk},
87 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 50, enc: promchunk.PrometheusXorChunk},
88 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 100, enc: promchunk.PrometheusXorChunk},
89 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 30 * time.Second, seekStep: 30 * time.Second * 200, enc: promchunk.PrometheusXorChunk},
90
91 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second / 2, enc: promchunk.PrometheusXorChunk},
92 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second, enc: promchunk.PrometheusXorChunk},
93 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 2, enc: promchunk.PrometheusXorChunk},
94 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 10, enc: promchunk.PrometheusXorChunk},
95 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 30, enc: promchunk.PrometheusXorChunk},
96 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 50, enc: promchunk.PrometheusXorChunk},
97 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 100, enc: promchunk.PrometheusXorChunk},
98 {numChunks: 1000, numSamplesPerChunk: 120, duplicationFactor: 3, scrapeInterval: 10 * time.Second, seekStep: 10 * time.Second * 200, enc: promchunk.PrometheusXorChunk},
99 }
100
101 for _, scenario := range scenarios {
102 name := fmt.Sprintf("scrapeInterval %vs seekStep: %vs",
103 scenario.scrapeInterval.Seconds(),
104 scenario.seekStep.Seconds())
105
106 chunks := createChunks(b, scenario.scrapeInterval, scenario.numChunks, scenario.numSamplesPerChunk, scenario.duplicationFactor, scenario.enc)
107
108 b.Run(name, func(b *testing.B) {
109 b.ReportAllocs()
110 var it chunkenc.Iterator
111 for b.Loop() {
112 it = NewChunkMergeIterator(it, chunks, 0, 0)
113 i := int64(0)
114 for it.Seek(i*scenario.seekStep.Milliseconds()) != chunkenc.ValNone {
115 i++
116 }
117 }
118 })
119 }
120}
121
122func TestSeekCorrectlyDealWithSinglePointChunks(t *testing.T) {
123 histograms := histogram_util.GenerateTestHistograms(1000, 1000, 1)

Callers

nothing calls this directly

Calls 5

createChunksFunction · 0.85
NewChunkMergeIteratorFunction · 0.85
LoopMethod · 0.80
RunMethod · 0.65
SeekMethod · 0.65

Tested by

no test coverage detected