BenchmarkIterator_Rewind tests rewind operation performance
(b *testing.B)
| 269 | |
| 270 | // BenchmarkIterator_Rewind tests rewind operation performance |
| 271 | func 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 |
| 301 | func BenchmarkIterator_PartialScan(b *testing.B) { |
nothing calls this directly
no test coverage detected