MCPcopy
hub / github.com/IBM/sarama / benchmarkProduceRequestEncodeMetrics

Function benchmarkProduceRequestEncodeMetrics

produce_request_test.go:156–184  ·  view source on GitHub ↗
(b *testing.B, partitions int)

Source from the content-addressed store, hash-verified

154}
155
156func benchmarkProduceRequestEncodeMetrics(b *testing.B, partitions int) {
157 b.Helper()
158
159 produceReq := &ProduceRequest{
160 RequiredAcks: WaitForLocal,
161 Timeout: 1_000,
162 }
163 for partition := range partitions {
164 produceReq.AddMessage("bench.topic", int32(partition), &Message{
165 Codec: CompressionNone,
166 Value: []byte("payload"),
167 })
168 }
169
170 req := &request{
171 correlationID: 1,
172 clientID: "bench",
173 body: produceReq,
174 }
175 metricRegistry := NewConfig().MetricRegistry
176
177 b.ReportAllocs()
178
179 for b.Loop() {
180 if _, err := encode(req, metricRegistry); err != nil {
181 b.Fatal(err)
182 }
183 }
184}
185
186func BenchmarkProduceRequestEncodeMetrics1Partition(b *testing.B) {
187 benchmarkProduceRequestEncodeMetrics(b, 1)

Calls 5

AddMessageMethod · 0.95
encodeFunction · 0.85
HelperMethod · 0.80
FatalMethod · 0.80
NewConfigFunction · 0.70

Tested by

no test coverage detected