]> Sergey Matveev's repositories - btrtrc.git/blobdiff - undirtied-chunks-iter_test.go
Drop support for go 1.20
[btrtrc.git] / undirtied-chunks-iter_test.go
index e811410e53773f04b897980ddd4c476ff4472d33..9ee6ecf402f41268a76035708e2c639163e11e89 100644 (file)
@@ -6,17 +6,14 @@ import (
        typedRoaring "github.com/anacrolix/torrent/typed-roaring"
 )
 
-func BenchmarkUndirtiedChunksIter(b *testing.B) {
+func BenchmarkIterUndirtiedRequestIndexesInPiece(b *testing.B) {
        var bitmap typedRoaring.Bitmap[RequestIndex]
-       a := undirtiedChunksIter{
-               TorrentDirtyChunks: &bitmap,
-               StartRequestIndex:  69,
-               EndRequestIndex:    420,
-       }
+       it := bitmap.IteratorType()
        b.ReportAllocs()
        for i := 0; i < b.N; i++ {
-               a.Iter(func(chunkIndex chunkIndexType) {
-
-               })
+               // This is the worst case, when Torrent.iterUndirtiedRequestIndexesInPiece can't find a
+               // usable cached iterator. This should be the only allocation.
+               it.Initialize(&bitmap)
+               iterBitmapUnsetInRange(&it, 69, 420, func(RequestIndex) {})
        }
 }