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

Function BenchmarkSparseAdvanceRoaring

benchmark_test.go:644–677  ·  view source on GitHub ↗

go test -bench BenchmarkSparseAdvance -run -

(b *testing.B)

Source from the content-addressed store, hash-verified

642
643// go test -bench BenchmarkSparseAdvance -run -
644func BenchmarkSparseAdvanceRoaring(b *testing.B) {
645 b.StopTimer()
646
647 s := NewBitmap()
648 initsize := 65000
649
650 for i := 0; i < initsize; i++ {
651 s.Add(uint32(i))
652 }
653
654 for _, gap := range []int{1, 2, 65, 650} {
655 b.Run(fmt.Sprintf("advance from %d", gap), func(b *testing.B) {
656 b.ReportAllocs()
657 b.StartTimer()
658
659 diff := uint32(0)
660
661 for n := 0; n < b.N; n++ {
662 val := uint32((gap * n) % initsize)
663
664 i := s.Iterator()
665 i.AdvanceIfNeeded(val)
666
667 diff += i.PeekNext() - val
668 }
669
670 b.StopTimer()
671
672 if diff != 0 {
673 b.Fatalf("Expected diff 0, got %d", diff)
674 }
675 })
676 }
677}
678
679// go test -bench BenchmarkSparseAdvance -run -
680func BenchmarkSparseAdvanceOnHugeData(b *testing.B) {

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
IteratorMethod · 0.95
NewBitmapFunction · 0.70
AdvanceIfNeededMethod · 0.65
PeekNextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…