Merge pull request #1763 from seebs/seebs/bench

improve  sliceascending/slicedescending benchmarks.
This commit is contained in:
seebs 2019-01-18 09:17:00 -06:00 committed by GitHub
commit 8762c2a4dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View file

@ -163,9 +163,8 @@ func (b *Bitmap) Add(a ...uint64) (changed bool, err error) {
}
// Apply to the in-memory bitmap.
if op.apply(b) {
if b.DirectAdd(v) {
changed = true
}
}

View file

@ -1498,6 +1498,41 @@ func BenchmarkSliceDescending(b *testing.B) {
for col := uint64(pilosa.ShardWidth); col > uint64(0); col-- {
bm.Add(col)
}
bm.Add(0)
}
}
func BenchmarkSliceAscendingStriped(b *testing.B) {
for n := 0; n < b.N; n++ {
bm := roaring.NewFileBitmap()
l := uint64(pilosa.ShardWidth / 8)
for col := uint64(0); col < l; col++ {
bm.Add(l*0 + col)
bm.Add(l*1 + col)
bm.Add(l*2 + col)
bm.Add(l*3 + col)
bm.Add(l*4 + col)
bm.Add(l*5 + col)
bm.Add(l*6 + col)
bm.Add(l*7 + col)
}
}
}
func BenchmarkSliceDescendingStriped(b *testing.B) {
for n := 0; n < b.N; n++ {
bm := roaring.NewFileBitmap()
l := uint64(pilosa.ShardWidth / 8)
for col := uint64(l); col < l+1; col-- {
bm.Add(l*7 + col)
bm.Add(l*6 + col)
bm.Add(l*5 + col)
bm.Add(l*4 + col)
bm.Add(l*3 + col)
bm.Add(l*2 + col)
bm.Add(l*1 + col)
bm.Add(l*0 + col)
}
}
}