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

Function BenchmarkSparseContains

benchmark_test.go:761–784  ·  view source on GitHub ↗

go test -bench BenchmarkSparseContains -run -

(b *testing.B)

Source from the content-addressed store, hash-verified

759
760// go test -bench BenchmarkSparseContains -run -
761func BenchmarkSparseContains(b *testing.B) {
762 b.StopTimer()
763 r := rand.New(rand.NewSource(0))
764 s := NewBitmap()
765 sz := 10000000
766 initsize := 65000
767 for i := 0; i < initsize; i++ {
768 s.Add(uint32(r.Int31n(int32(sz))))
769 }
770 var a [1024]uint32
771 for i := 0; i < 1024; i++ {
772 a[i] = uint32(r.Int31n(int32(sz)))
773 }
774 b.StartTimer()
775 for j := 0; j < b.N; j++ {
776 c9 = uint(0)
777 for i := 0; i < 1024; i++ {
778 if s.Contains(a[i]) {
779 c9++
780 }
781
782 }
783 }
784}
785
786// go test -bench BenchmarkSparseIterate -run -
787func BenchmarkSparseIterateBitset(b *testing.B) {

Callers

nothing calls this directly

Calls 3

AddMethod · 0.95
ContainsMethod · 0.95
NewBitmapFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…