FedP2P/undirtied-chunks-iter_test.go

20 lines
533 B
Go
Raw Normal View History

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