From 67e3dc4a089af02574b92005f2ab0ac5e21b92f7 Mon Sep 17 00:00:00 2001 From: Seebs Date: Mon, 26 Nov 2018 13:10:21 -0600 Subject: [PATCH] roaring: improve SliceAscending/SliceDescending tests Two changes: First, make SliceDescending set the entire slice, not all-but-one bits. Second, add tests that are "striped", so it's writing to 8 parts of the slice sequentially, rather than just going up or down the whole thing, because that gives us some cheap indication of cache-locality impact, which turns out to be possibly significant. --- roaring/roaring_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index f5c016ea3..a55393f1b 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -1348,5 +1348,40 @@ 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) + } } }