diff --git a/sdk/metric/benchmark_test.go b/sdk/metric/benchmark_test.go index 27266e3ca35..c083f3aa9e7 100644 --- a/sdk/metric/benchmark_test.go +++ b/sdk/metric/benchmark_test.go @@ -528,3 +528,40 @@ func BenchmarkFloat64ArrayAdd(b *testing.B) { func BenchmarkFloat64ArrayHandleAdd(b *testing.B) { benchmarkFloat64MeasureHandleAdd(b, "float64.array") } + +// BatchRecord + +func benchmarkBatchRecord8Labels(b *testing.B, numInst int) { + const numLabels = 8 + ctx := context.Background() + fix := newFixture(b) + labs := makeLabels(numLabels) + var meas []metric.Measurement + + for i := 0; i < numInst; i++ { + inst := fix.meter.NewInt64Counter(fmt.Sprint("int64.counter.", i)) + meas = append(meas, inst.Measurement(1)) + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + fix.sdk.RecordBatch(ctx, fix.sdk.Labels(labs...), meas...) + } +} + +func BenchmarkBatchRecord8Labels_1Instrument(b *testing.B) { + benchmarkBatchRecord8Labels(b, 1) +} + +func BenchmarkBatchRecord_8Labels_2Instruments(b *testing.B) { + benchmarkBatchRecord8Labels(b, 2) +} + +func BenchmarkBatchRecord_8Labels_4Instruments(b *testing.B) { + benchmarkBatchRecord8Labels(b, 4) +} + +func BenchmarkBatchRecord_8Labels_8Instruments(b *testing.B) { + benchmarkBatchRecord8Labels(b, 8) +}