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

Function BenchmarkSparseAdvanceSequentially

benchmark_test.go:703–739  ·  view source on GitHub ↗

go test -bench BenchmarkSparseAdvance -run -

(b *testing.B)

Source from the content-addressed store, hash-verified

701
702// go test -bench BenchmarkSparseAdvance -run -
703func BenchmarkSparseAdvanceSequentially(b *testing.B) {
704 b.StopTimer()
705
706 s := NewBitmap()
707 initsize := 65000
708
709 for i := 0; i < initsize; i++ {
710 s.Add(uint32(i))
711 }
712
713 for _, gap := range []int{1, 2, 65, 650} {
714 b.Run(fmt.Sprintf("advance from %d", gap), func(b *testing.B) {
715 b.ReportAllocs()
716 b.StartTimer()
717
718 diff := uint32(0)
719
720 for n := 0; n < b.N; n++ {
721 val := uint32((gap * n) % initsize)
722
723 i := s.Iterator()
724
725 for i.HasNext() && i.PeekNext() < val {
726 i.Next()
727 }
728
729 diff += i.PeekNext() - val
730 }
731
732 b.StopTimer()
733
734 if diff != 0 {
735 b.Fatalf("Expected diff 0, got %d", diff)
736 }
737 })
738 }
739}
740
741// go test -bench BenchmarkIterate -run -
742func BenchmarkIterateBitset(b *testing.B) {

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
IteratorMethod · 0.95
NewBitmapFunction · 0.70
HasNextMethod · 0.65
PeekNextMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…