| 1264 | } |
| 1265 | |
| 1266 | func 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 | |
| 1295 | func benchmarkConnReadOffsets(b *testing.B, conn *Conn, _ []byte) { |
| 1296 | for i := 0; i != b.N; i++ { |