MCPcopy Index your code
hub / github.com/nutsdb/nutsdb / BenchmarkIterator_MultipleIterators

Function BenchmarkIterator_MultipleIterators

iterator_bench_test.go:363–396  ·  view source on GitHub ↗

BenchmarkIterator_MultipleIterators tests overhead of multiple concurrent iterators

(b *testing.B)

Source from the content-addressed store, hash-verified

361
362// BenchmarkIterator_MultipleIterators tests overhead of multiple concurrent iterators
363func 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
399func BenchmarkIterator_LargeValues(b *testing.B) {

Callers

nothing calls this directly

Calls 8

setupIteratorBenchmarkFunction · 0.85
NewIteratorFunction · 0.85
ViewMethod · 0.80
KeyMethod · 0.80
NextMethod · 0.80
CloseMethod · 0.65
ReleaseMethod · 0.65
ValidMethod · 0.45

Tested by

no test coverage detected