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

Function BenchmarkEncoderPoolPutDifferentSizes

pkg/ingest/encoding_test.go:236–270  ·  view source on GitHub ↗

Benchmark with different request sizes to see scaling behavior

(b *testing.B)

Source from the content-addressed store, hash-verified

234
235// Benchmark with different request sizes to see scaling behavior
236func BenchmarkEncoderPoolPutDifferentSizes(b *testing.B) {
237 sizes := []struct {
238 name string
239 entries int
240 length int
241 }{
242 {"Small", 10, 50},
243 {"Medium", 100, 200},
244 {"Large", 1000, 500},
245 }
246
247 for _, size := range sizes {
248 req := generateRequest(size.entries, size.length)
249
250 b.Run(size.name+"_Original", func(b *testing.B) {
251 b.ReportAllocs()
252 for i := 0; i < b.N; i++ {
253 pooled := encoderPool.Get().(*tempopb.PushBytesRequest)
254 pooled.Traces = append(pooled.Traces, req.Traces...)
255 pooled.Ids = append(pooled.Ids, req.Ids...)
256 encoderPoolPutOriginal(pooled)
257 }
258 })
259
260 b.Run(size.name+"_WithClear", func(b *testing.B) {
261 b.ReportAllocs()
262 for i := 0; i < b.N; i++ {
263 pooled := encoderPool.Get().(*tempopb.PushBytesRequest)
264 pooled.Traces = append(pooled.Traces, req.Traces...)
265 pooled.Ids = append(pooled.Ids, req.Ids...)
266 encoderPoolPut(pooled)
267 }
268 })
269 }
270}

Callers

nothing calls this directly

Calls 5

generateRequestFunction · 0.85
encoderPoolPutOriginalFunction · 0.85
encoderPoolPutFunction · 0.85
GetMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected