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

Function BenchmarkIterator_Rewind

iterator_bench_test.go:271–298  ·  view source on GitHub ↗

BenchmarkIterator_Rewind tests rewind operation performance

(b *testing.B)

Source from the content-addressed store, hash-verified

269
270// BenchmarkIterator_Rewind tests rewind operation performance
271func BenchmarkIterator_Rewind(b *testing.B) {
272 db, bucket := setupIteratorBenchmark(b, 10000)
273 defer func() { _ = db.Close() }()
274
275 b.ResetTimer()
276 b.ReportAllocs()
277
278 for i := 0; i < b.N; i++ {
279 err := db.View(func(tx *Tx) error {
280 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
281 defer iterator.Release()
282
283 // Move forward a bit
284 for j := 0; j < 100 && iterator.Valid(); j++ {
285 iterator.Next()
286 }
287
288 // Rewind back to start
289 if !iterator.Rewind() {
290 return fmt.Errorf("rewind failed")
291 }
292 return nil
293 })
294 if err != nil {
295 b.Fatalf("View failed: %v", err)
296 }
297 }
298}
299
300// BenchmarkIterator_PartialScan tests scanning a portion of data
301func BenchmarkIterator_PartialScan(b *testing.B) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected