Benchmark_HandlePRW2_PoolVsScratch compares two allocation strategies for the PRW2 parse path. - pool: req := cortexpb.PreallocWriteRequestV2FromPool() + defer ReuseWriteRequestV2(req) - scratch: var req cortexpb.PreallocWriteRequestV2 + defer ReuseWriteRequestV2(&req)
(b *testing.B)
| 262 | // - pool: req := cortexpb.PreallocWriteRequestV2FromPool() + defer ReuseWriteRequestV2(req) |
| 263 | // - scratch: var req cortexpb.PreallocWriteRequestV2 + defer ReuseWriteRequestV2(&req) |
| 264 | func Benchmark_HandlePRW2_PoolVsScratch(b *testing.B) { |
| 265 | var limits validation.Limits |
| 266 | flagext.DefaultValues(&limits) |
| 267 | overrides := validation.NewOverrides(limits, nil) |
| 268 | |
| 269 | userID := "bench-user" |
| 270 | seriesNum := 100 |
| 271 | ctx := user.InjectOrgID(context.Background(), userID) |
| 272 | |
| 273 | for _, symCount := range []int{32, 128, 512, 2048, 4096} { |
| 274 | body, contentLength := makeEncodedPRW2Body(b, seriesNum, symCount) |
| 275 | name := fmt.Sprintf("symbols=%d", symCount) |
| 276 | |
| 277 | b.Run("pool/"+name, func(b *testing.B) { |
| 278 | b.ReportAllocs() |
| 279 | for b.Loop() { |
| 280 | require.NoError(b, runPRW2HandleFromPool(ctx, body, contentLength, overrides, userID)) |
| 281 | } |
| 282 | }) |
| 283 | |
| 284 | b.Run("scratch/"+name, func(b *testing.B) { |
| 285 | b.ReportAllocs() |
| 286 | for b.Loop() { |
| 287 | require.NoError(b, runPRW2HandleFromScratch(ctx, body, contentLength, overrides, userID)) |
| 288 | } |
| 289 | }) |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | func Test_convertV2RequestToV1_WithEnableTypeAndUnitLabels(t *testing.T) { |
| 294 | symbols := []string{"", "__name__", "test_metric1", "b", "c", "baz", "qux", "d", "e", "foo", "bar", "f", "g", "h", "i", "Test gauge for test purposes", "Maybe op/sec who knows (:", "Test counter for test purposes", "__type__", "exist type", "__unit__", "exist unit"} |
nothing calls this directly
no test coverage detected