(b *testing.B, partitions int)
| 154 | } |
| 155 | |
| 156 | func 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 | |
| 186 | func BenchmarkProduceRequestEncodeMetrics1Partition(b *testing.B) { |
| 187 | benchmarkProduceRequestEncodeMetrics(b, 1) |
no test coverage detected