MCPcopy
hub / github.com/RoaringBitmap/roaring / BenchmarkIterateRoaring

Function BenchmarkIterateRoaring

benchmark_test.go:524–619  ·  view source on GitHub ↗

go test -bench BenchmarkIterate -run -

(b *testing.B)

Source from the content-addressed store, hash-verified

522
523// go test -bench BenchmarkIterate -run -
524func BenchmarkIterateRoaring(b *testing.B) {
525 newBitmap := func() *Bitmap {
526 r := rand.New(rand.NewSource(0))
527 s := NewBitmap()
528 sz := 150000
529 initsize := 65000
530 for i := 0; i < initsize; i++ {
531 s.Add(uint32(r.Int31n(int32(sz))))
532 }
533 return s
534 }
535
536 b.Run("iterator-compressed", func(b *testing.B) {
537 b.ReportAllocs()
538
539 s := newBitmap()
540 s.RunOptimize()
541
542 b.ResetTimer()
543
544 for j := 0; j < b.N; j++ {
545 c9 = uint(0)
546 i := s.Iterator()
547 for i.HasNext() {
548 i.Next()
549 c9++
550 }
551 }
552 })
553
554 b.Run("iterator", func(b *testing.B) {
555 b.ReportAllocs()
556
557 s := newBitmap()
558
559 b.ResetTimer()
560
561 for j := 0; j < b.N; j++ {
562 c9 = uint(0)
563 i := s.Iterator()
564 for i.HasNext() {
565 i.Next()
566 c9++
567 }
568 }
569 })
570
571 b.Run("iterate-compressed", func(b *testing.B) {
572 b.ReportAllocs()
573
574 s := newBitmap()
575 s.RunOptimize()
576
577 b.ResetTimer()
578
579 for j := 0; j < b.N; j++ {
580 c9 = uint(0)
581 s.Iterate(func(x uint32) bool {

Callers

nothing calls this directly

Calls 9

AddMethod · 0.95
RunOptimizeMethod · 0.95
IteratorMethod · 0.95
IterateMethod · 0.95
UnsetIteratorMethod · 0.95
NewBitmapFunction · 0.70
FlipFunction · 0.70
HasNextMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…