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) {})
}
}