BenchmarkIterator_MultipleIterators tests overhead of multiple concurrent iterators
(b *testing.B)
| 361 | |
| 362 | // BenchmarkIterator_MultipleIterators tests overhead of multiple concurrent iterators |
| 363 | func BenchmarkIterator_MultipleIterators(b *testing.B) { |
| 364 | db, bucket := setupIteratorBenchmark(b, 10000) |
| 365 | defer func() { _ = db.Close() }() |
| 366 | |
| 367 | b.ResetTimer() |
| 368 | b.ReportAllocs() |
| 369 | |
| 370 | for i := 0; i < b.N; i++ { |
| 371 | err := db.View(func(tx *Tx) error { |
| 372 | // Create 10 iterators |
| 373 | iterators := make([]*Iterator, 10) |
| 374 | for j := 0; j < 10; j++ { |
| 375 | iterators[j] = NewIterator(tx, bucket, IteratorOptions{Reverse: j%2 == 0}) |
| 376 | } |
| 377 | |
| 378 | // Use all iterators |
| 379 | for j := 0; j < 10; j++ { |
| 380 | if iterators[j].Valid() { |
| 381 | _ = iterators[j].Key() |
| 382 | iterators[j].Next() |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | // Release all iterators |
| 387 | for j := 0; j < 10; j++ { |
| 388 | iterators[j].Release() |
| 389 | } |
| 390 | return nil |
| 391 | }) |
| 392 | if err != nil { |
| 393 | b.Fatalf("View failed: %v", err) |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | // BenchmarkIterator_LargeValues tests iteration with large values |
| 399 | func BenchmarkIterator_LargeValues(b *testing.B) { |
nothing calls this directly
no test coverage detected