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

Function benchmarkConnReadBatch

conn_test.go:1266–1293  ·  view source on GitHub ↗
(b *testing.B, conn *Conn, a []byte)

Source from the content-addressed store, hash-verified

1264}
1265
1266func benchmarkConnReadBatch(b *testing.B, conn *Conn, a []byte) {
1267 const minBytes = 1
1268 const maxBytes = 10e6 // 10 MB
1269
1270 batch := conn.ReadBatch(minBytes, maxBytes)
1271 i := 0
1272 n := 0
1273
1274 for i != b.N {
1275 c, err := batch.Read(a)
1276 if err != nil {
1277 if err = batch.Close(); err != nil {
1278 b.Error(err)
1279 return
1280 }
1281 if _, err = conn.Seek(0, SeekStart); err != nil {
1282 b.Error(err)
1283 return
1284 }
1285 batch = conn.ReadBatch(minBytes, maxBytes)
1286 }
1287 n += c
1288 i++
1289 }
1290
1291 batch.Close()
1292 b.SetBytes(int64(n / i))
1293}
1294
1295func benchmarkConnReadOffsets(b *testing.B, conn *Conn, _ []byte) {
1296 for i := 0; i != b.N; i++ {

Callers

nothing calls this directly

Calls 5

ReadBatchMethod · 0.80
ReadMethod · 0.45
CloseMethod · 0.45
ErrorMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected