MCPcopy
hub / github.com/segmentio/kafka-go / BenchmarkProduceRequest

Function BenchmarkProduceRequest

protocol/rawproduce/rawproduce_test.go:143–201  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

141}
142
143func BenchmarkProduceRequest(b *testing.B) {
144 t0 := time.Now().Truncate(time.Millisecond)
145 t1 := t0.Add(1 * time.Millisecond)
146 t2 := t0.Add(2 * time.Millisecond)
147
148 prototest.BenchmarkRequest(b, v3, &rawproduce.Request{
149 TransactionalID: "1234",
150 Acks: 1,
151 Timeout: 500,
152 Topics: []rawproduce.RequestTopic{
153 {
154 Topic: "topic-1",
155 Partitions: []rawproduce.RequestPartition{
156 {
157 Partition: 0,
158 RecordSet: NewRawRecordSet(protocol.NewRecordReader(
159 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: nil},
160 ), 1, 0),
161 },
162 {
163 Partition: 1,
164 RecordSet: NewRawRecordSet(protocol.NewRecordReader(
165 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0")},
166 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
167 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
168 ), 1, 0),
169 },
170 },
171 },
172 },
173 })
174
175 headers := []protocol.Header{
176 {Key: "key-1", Value: []byte("value-1")},
177 {Key: "key-2", Value: []byte("value-2")},
178 {Key: "key-3", Value: []byte("value-3")},
179 }
180
181 prototest.BenchmarkRequest(b, v5, &rawproduce.Request{
182 TransactionalID: "1234",
183 Acks: 1,
184 Timeout: 500,
185 Topics: []rawproduce.RequestTopic{
186 {
187 Topic: "topic-1",
188 Partitions: []rawproduce.RequestPartition{
189 {
190 Partition: 1,
191 RecordSet: NewRawRecordSet(protocol.NewRecordReader(
192 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0"), Headers: headers},
193 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
194 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
195 ), 2, 0),
196 },
197 },
198 },
199 },
200 })

Callers

nothing calls this directly

Calls 6

BenchmarkRequestFunction · 0.92
NewRecordReaderFunction · 0.92
StringFunction · 0.92
BytesFunction · 0.92
NewRawRecordSetFunction · 0.70
TruncateMethod · 0.45

Tested by

no test coverage detected