forked from RoaringBitmap/roaring
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parallel_benchmark_test.go
57 lines (47 loc) · 1.01 KB
/
parallel_benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package roaring
import (
"math/rand"
"testing"
)
func BenchmarkIntersectionLargeParallel(b *testing.B) {
b.StopTimer()
initsize := 650000
r := rand.New(rand.NewSource(0))
s1 := NewBitmap()
sz := 150 * 1000 * 1000
for i := 0; i < initsize; i++ {
s1.Add(uint32(r.Int31n(int32(sz))))
}
s2 := NewBitmap()
sz = 100 * 1000 * 1000
for i := 0; i < initsize; i++ {
s2.Add(uint32(r.Int31n(int32(sz))))
}
b.StartTimer()
card := uint64(0)
for j := 0; j < b.N; j++ {
s3 := ParAnd(0, s1, s2)
card = card + s3.GetCardinality()
}
}
func BenchmarkIntersectionLargeRoaring(b *testing.B) {
b.StopTimer()
initsize := 650000
r := rand.New(rand.NewSource(0))
s1 := NewBitmap()
sz := 150 * 1000 * 1000
for i := 0; i < initsize; i++ {
s1.Add(uint32(r.Int31n(int32(sz))))
}
s2 := NewBitmap()
sz = 100 * 1000 * 1000
for i := 0; i < initsize; i++ {
s2.Add(uint32(r.Int31n(int32(sz))))
}
b.StartTimer()
card := uint64(0)
for j := 0; j < b.N; j++ {
s3 := And(s1, s2)
card = card + s3.GetCardinality()
}
}