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