2022-05-09 09:10:57 +08:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-05-09 09:34:08 +08:00
|
|
|
typedRoaring "github.com/anacrolix/torrent/typed-roaring"
|
2022-05-09 09:10:57 +08:00
|
|
|
)
|
|
|
|
|
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()
|
2022-05-09 09:10:57 +08:00
|
|
|
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) {})
|
2022-05-09 09:10:57 +08:00
|
|
|
}
|
|
|
|
}
|