Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add benchmark test for multi batch processing #7717

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,20 @@ func BenchmarkBatchMetricProcessor(b *testing.B) {
Timeout: 100 * time.Millisecond,
SendBatchSize: 2000,
}
runMetricsProcessorBenchmark(b, cfg)
}

func BenchmarkMultiBatchMetricProcessor(b *testing.B) {
b.StopTimer()
cfg := Config{
Timeout: 100 * time.Millisecond,
SendBatchSize: 2000,
MetadataKeys: []string{"test", "test2"},
}
runMetricsProcessorBenchmark(b, cfg)
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
}

func runMetricsProcessorBenchmark(b *testing.B, cfg Config) {
ctx := context.Background()
sink := new(metricsSink)
creationSet := processortest.NewNopCreateSettings()
Expand All @@ -620,16 +634,12 @@ func BenchmarkBatchMetricProcessor(b *testing.B) {
require.NoError(b, err)
require.NoError(b, batcher.Start(ctx, componenttest.NewNopHost()))

mds := make([]pmetric.Metrics, 0, b.N)
for n := 0; n < b.N; n++ {
mds = append(mds,
testdata.GenerateMetrics(metricsPerRequest),
)
}
b.StartTimer()
for n := 0; n < b.N; n++ {
require.NoError(b, batcher.ConsumeMetrics(ctx, mds[n]))
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
require.NoError(b, batcher.ConsumeMetrics(ctx, testdata.GenerateMetrics(metricsPerRequest)))
}
})
b.StopTimer()
require.NoError(b, batcher.Shutdown(ctx))
require.Equal(b, b.N*metricsPerRequest, sink.metricsCount)
Expand Down