1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-03 22:52:30 +02:00

Add a RecordBatch benchmark (#594)

This commit is contained in:
Joshua MacDonald 2020-03-25 08:57:40 -07:00 committed by GitHub
parent 4c69dd3234
commit cfe74cf91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}