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

Function benchmarkSeriesMap

pkg/ingester/client/compat_test.go:83–105  ·  view source on GitHub ↗
(numSeries int, b *testing.B)

Source from the content-addressed store, hash-verified

81}
82
83func benchmarkSeriesMap(numSeries int, b *testing.B) {
84 series := makeSeries(numSeries)
85 sm := make(map[string]int, numSeries)
86
87 b.ReportAllocs()
88
89 for b.Loop() {
90 for i, s := range series {
91 sm[LabelsToKeyString(s)] = i
92 }
93
94 for _, s := range series {
95 _, ok := sm[LabelsToKeyString(s)]
96 if !ok {
97 b.Fatal("element missing")
98 }
99 }
100
101 if len(sm) != numSeries {
102 b.Fatal("the number of series expected:", numSeries, "got:", len(sm))
103 }
104 }
105}
106
107func makeSeries(n int) []labels.Labels {
108 series := make([]labels.Labels, 0, n)

Callers 1

BenchmarkSeriesMapFunction · 0.85

Calls 3

makeSeriesFunction · 0.85
LabelsToKeyStringFunction · 0.85
LoopMethod · 0.80

Tested by

no test coverage detected