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

Function BenchmarkNextsRLE

benchmark_test.go:986–1024  ·  view source on GitHub ↗

go test -bench BenchmarkRLENexts -benchmem -run -

(b *testing.B)

Source from the content-addressed store, hash-verified

984
985// go test -bench BenchmarkRLENexts -benchmem -run -
986func BenchmarkNextsRLE(b *testing.B) {
987
988 var totadd uint64
989 var totaddmany uint64
990
991 bm := NewBitmap()
992 bm.AddRange(0, 1000000)
993
994 b.Run("next", func(b *testing.B) {
995 for n := 0; n < b.N; n++ {
996 totadd = 0
997 iter := bm.Iterator()
998 for iter.HasNext() {
999 v := iter.Next()
1000 totadd += uint64(v)
1001 }
1002 }
1003 b.StopTimer()
1004 })
1005
1006 b.Run("nextmany", func(b *testing.B) {
1007 for n := 0; n < b.N; n++ {
1008 totaddmany = 0
1009 iter := bm.ManyIterator()
1010 // worst case, in practice will reuse buffers across many roars
1011 buf := make([]uint32, 2048)
1012 for j := iter.NextMany(buf); j != 0; j = iter.NextMany(buf) {
1013 for i := 0; i < j; i++ {
1014 totaddmany += uint64(buf[i])
1015 }
1016 }
1017 }
1018 b.StopTimer()
1019 })
1020 if totadd != totaddmany {
1021 b.Fatalf("Cardinalities don't match: %d, %d", totadd, totaddmany)
1022 }
1023
1024}
1025
1026func BenchmarkXor(b *testing.B) {
1027 b.StopTimer()

Callers

nothing calls this directly

Calls 7

AddRangeMethod · 0.95
IteratorMethod · 0.95
ManyIteratorMethod · 0.95
NewBitmapFunction · 0.70
HasNextMethod · 0.65
NextMethod · 0.65
NextManyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…