go test -bench BenchmarkRLENexts -benchmem -run -
(b *testing.B)
| 984 | |
| 985 | // go test -bench BenchmarkRLENexts -benchmem -run - |
| 986 | func 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 | |
| 1026 | func BenchmarkXor(b *testing.B) { |
| 1027 | b.StopTimer() |
nothing calls this directly
no test coverage detected
searching dependent graphs…