Skip to content

Commit

Permalink
Add a RecordBatch benchmark (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacd committed Mar 25, 2020
1 parent 4c69dd3 commit cfe74cf
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions sdk/metric/benchmark_test.go
Expand Up @@ -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)
}

0 comments on commit cfe74cf

Please sign in to comment.