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

Function BenchmarkIterator_Creation

iterator_bench_test.go:61–81  ·  view source on GitHub ↗

BenchmarkIterator_Creation tests iterator creation overhead

(b *testing.B)

Source from the content-addressed store, hash-verified

59
60// BenchmarkIterator_Creation tests iterator creation overhead
61func BenchmarkIterator_Creation(b *testing.B) {
62 db, bucket := setupIteratorBenchmark(b, 10000)
63 defer func() { _ = db.Close() }()
64
65 b.ResetTimer()
66 b.ReportAllocs()
67
68 for i := 0; i < b.N; i++ {
69 err := db.View(func(tx *Tx) error {
70 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
71 if iterator == nil {
72 b.Fatal("Failed to create iterator")
73 }
74 iterator.Release()
75 return nil
76 })
77 if err != nil {
78 b.Fatalf("View failed: %v", err)
79 }
80 }
81}
82
83// BenchmarkIterator_Next tests forward iteration performance
84func BenchmarkIterator_Next(b *testing.B) {

Callers

nothing calls this directly

Calls 5

ReleaseMethod · 0.95
setupIteratorBenchmarkFunction · 0.85
NewIteratorFunction · 0.85
ViewMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected