mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 07:41:02 +00:00
roaring: speed-up intersectionCountArrayBitmap
While looking at benchmarks as a possible go compiler benchmarks. I've tried some optimizations by hand: Move len(b.bitmap) load out of the loop. Remove some type conversions. Use (x >> off) & 1 to get offs bit, instead of x & (1 << of)f >> off. This produces nice speed-up and passes go test roaring. name old time/op new time/op delta Bitmap_IntersectionCount_ArrayRun-6 2.06µs ± 0% 1.57µs ± 0% -24.04% (p=0.000 n=10+9) Bitmap_IntersectionCount_BitmapRun-6 2.24µs ± 0% 2.24µs ± 0% ~ (p=0.913 n=10+9) Bitmap_IntersectionCount_ArrayBitmap-6 2.06µs ± 0% 1.56µs ± 1% -24.05% (p=0.000 n=9+10)
This commit is contained in:
parent
280b21b533
commit
2c8d9a5ae0
1 changed files with 4 additions and 3 deletions
|
|
@ -1907,13 +1907,14 @@ func intersectionCountBitmapRun(a, b *container) (n int) {
|
|||
}
|
||||
|
||||
func intersectionCountArrayBitmap(a, b *container) (n int) {
|
||||
ln := len(b.bitmap)
|
||||
for _, val := range a.array {
|
||||
i := val >> 6
|
||||
if i >= uint16(len(b.bitmap)) {
|
||||
i := int(val >> 6)
|
||||
if i >= ln {
|
||||
break
|
||||
}
|
||||
off := val % 64
|
||||
n += int((b.bitmap[i] & (1 << off)) >> off)
|
||||
n += int(b.bitmap[i]>>off) & 1
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue