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

Function benchmarkContainerIteratorAdvance

container_test.go:142–168  ·  view source on GitHub ↗
(b *testing.B, con container)

Source from the content-addressed store, hash-verified

140}
141
142func benchmarkContainerIteratorAdvance(b *testing.B, con container) {
143 for _, initsize := range []int{1, 650, 6500, MaxUint16} {
144 for i := 0; i < initsize; i++ {
145 con.iadd(uint16(i))
146 }
147
148 b.Run(fmt.Sprintf("init size %d shortIterator advance", initsize), func(b *testing.B) {
149 b.StartTimer()
150 diff := uint16(0)
151
152 for n := 0; n < b.N; n++ {
153 val := uint16(n % initsize)
154
155 i := con.getShortIterator()
156 i.advanceIfNeeded(val)
157
158 diff += i.peekNext() - val
159 }
160
161 b.StopTimer()
162
163 if diff != 0 {
164 b.Fatalf("Expected diff 0, got %d", diff)
165 }
166 })
167 }
168}
169
170func benchmarkContainerIteratorNext(b *testing.B, con container) {
171 for _, initsize := range []int{1, 650, 6500, MaxUint16} {

Calls 4

iaddMethod · 0.65
getShortIteratorMethod · 0.65
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…