MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkMergedSeriesSet

Function BenchmarkMergedSeriesSet

tsdb/querier_test.go:2267–2313  ·  view source on GitHub ↗

Test the cost of merging series sets for different number of merged sets and their size. The subset are all equivalent so this does not capture merging of partial or non-overlapping sets well. TODO(bwplotka): Merge with storage merged series set benchmark.

(b *testing.B)

Source from the content-addressed store, hash-verified

2265// The subset are all equivalent so this does not capture merging of partial or non-overlapping sets well.
2266// TODO(bwplotka): Merge with storage merged series set benchmark.
2267func BenchmarkMergedSeriesSet(b *testing.B) {
2268 sel := func(sets []storage.SeriesSet) storage.SeriesSet {
2269 return storage.NewMergeSeriesSet(sets, 0, storage.ChainedSeriesMerge)
2270 }
2271
2272 for _, k := range []int{
2273 100,
2274 1000,
2275 10000,
2276 20000,
2277 } {
2278 for _, j := range []int{1, 2, 4, 8, 16, 32} {
2279 b.Run(fmt.Sprintf("series=%d,blocks=%d", k, j), func(b *testing.B) {
2280 lbls, err := labels.ReadLabels(filepath.Join("testdata", "20kseries.json"), k)
2281 require.NoError(b, err)
2282
2283 sort.Sort(labels.Slice(lbls))
2284
2285 in := make([][]storage.Series, j)
2286
2287 for _, l := range lbls {
2288 l2 := l
2289 for j := range in {
2290 in[j] = append(in[j], storage.NewListSeries(l2, nil))
2291 }
2292 }
2293
2294 b.ResetTimer()
2295
2296 for b.Loop() {
2297 var sets []storage.SeriesSet
2298 for _, s := range in {
2299 sets = append(sets, newMockSeriesSet(s))
2300 }
2301 ms := sel(sets)
2302
2303 i := 0
2304 for ms.Next() {
2305 i++
2306 }
2307 require.NoError(b, ms.Err())
2308 require.Len(b, lbls, i)
2309 }
2310 })
2311 }
2312 }
2313}
2314
2315type mockChunkReader map[chunks.ChunkRef]chunkenc.Chunk
2316

Callers

nothing calls this directly

Calls 10

NewMergeSeriesSetFunction · 0.92
ReadLabelsFunction · 0.92
SliceTypeAlias · 0.92
NewListSeriesFunction · 0.92
newMockSeriesSetFunction · 0.85
RunMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
LenMethod · 0.65
SortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…