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

Function BenchmarkIterator_Next

iterator_bench_test.go:84–115  ·  view source on GitHub ↗

BenchmarkIterator_Next tests forward iteration performance

(b *testing.B)

Source from the content-addressed store, hash-verified

82
83// BenchmarkIterator_Next tests forward iteration performance
84func BenchmarkIterator_Next(b *testing.B) {
85 sizes := []int{100, 1000, 10000}
86
87 for _, size := range sizes {
88 b.Run(fmt.Sprintf("Size_%d", size), func(b *testing.B) {
89 db, bucket := setupIteratorBenchmark(b, size)
90 defer func() { _ = db.Close() }()
91
92 b.ResetTimer()
93 b.ReportAllocs()
94
95 for i := 0; i < b.N; i++ {
96 err := db.View(func(tx *Tx) error {
97 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
98 defer iterator.Release()
99
100 count := 0
101 for iterator.Valid() {
102 count++
103 if !iterator.Next() {
104 break
105 }
106 }
107 return nil
108 })
109 if err != nil {
110 b.Fatalf("View failed: %v", err)
111 }
112 }
113 })
114 }
115}
116
117// BenchmarkIterator_Prev tests reverse iteration performance
118func BenchmarkIterator_Prev(b *testing.B) {

Callers

nothing calls this directly

Calls 8

ReleaseMethod · 0.95
ValidMethod · 0.95
NextMethod · 0.95
setupIteratorBenchmarkFunction · 0.85
NewIteratorFunction · 0.85
RunMethod · 0.80
ViewMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected