torrent/undirtied-chunks-iter_test.go

20 lines
533 B
Go
Raw Normal View History

package torrent
import (
"testing"
2022-05-09 01:34:08 +00:00
typedRoaring "github.com/anacrolix/torrent/typed-roaring"
)
2022-05-11 01:20:52 +00:00
func BenchmarkIterUndirtiedRequestIndexesInPiece(b *testing.B) {
2022-05-09 01:34:08 +00:00
var bitmap typedRoaring.Bitmap[RequestIndex]
2022-05-11 01:20:52 +00:00
it := bitmap.IteratorType()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
2022-05-11 01:20:52 +00:00
// 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) {})
}
}