MCPcopy
hub / github.com/grafana/tempo / BenchmarkCombine

Function BenchmarkCombine

pkg/model/trace/combine_test.go:166–210  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

164}
165
166func BenchmarkCombine(b *testing.B) {
167 parts := []int{2, 3, 4, 8}
168 requests := 100 // 100K spans per part
169 spansEach := 1000
170 id := test.ValidTraceID(nil)
171
172 methods := []struct {
173 name string
174 method func(traces []*tempopb.Trace) int
175 }{
176 {
177 "Combiner",
178 func(traces []*tempopb.Trace) int {
179 c := NewCombiner(0, false)
180 for i := range traces {
181 _, err := c.ConsumeWithFinal(traces[i], i == len(traces)-1)
182 require.NoError(b, err)
183 }
184 _, spanCount := c.Result()
185 return spanCount
186 },
187 },
188 }
189 for _, p := range parts {
190 b.Run(strconv.Itoa(p), func(b *testing.B) {
191 for _, m := range methods {
192 b.Run(m.name, func(b *testing.B) {
193 for n := 0; n < b.N; n++ {
194
195 // Generate input data. Since combination is destructive
196 // this must be done each time.
197 b.StopTimer()
198 var traces []*tempopb.Trace
199 for i := 0; i < p; i++ {
200 traces = append(traces, test.MakeTraceWithSpanCount(requests, spansEach, id))
201 }
202 b.StartTimer()
203
204 m.method(traces)
205 }
206 })
207 }
208 })
209 }
210}

Callers

nothing calls this directly

Calls 6

ConsumeWithFinalMethod · 0.95
ResultMethod · 0.95
ValidTraceIDFunction · 0.92
MakeTraceWithSpanCountFunction · 0.92
NewCombinerFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected