-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench_test.go
More file actions
48 lines (35 loc) · 729 Bytes
/
bench_test.go
File metadata and controls
48 lines (35 loc) · 729 Bytes
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
package bitset_test
import (
"bitset"
"fmt"
"math"
"math/rand"
"testing"
wb "github.com/willf/bitset"
)
var benchConfigs = [][]uint{
[]uint{32},
[]uint{16, 16},
[]uint{14, 12, 6},
[]uint{8, 8, 8, 8},
[]uint{10, 8, 6, 4, 4},
[]uint{4, 4, 4, 4, 4, 4, 4, 4},
}
func BenchmarkBitsetSet(bench *testing.B) {
for _, cfg := range benchConfigs {
b := bitset.New(cfg)
bench.Run(fmt.Sprintf("%v", cfg), func(bench *testing.B) {
bench.ReportAllocs()
for i := 0; i < bench.N; i++ {
b.Set(uint64(rand.Int31()))
}
})
}
b2 := wb.New(uint(math.MaxInt64))
bench.Run("willf:32", func(bench *testing.B) {
bench.ReportAllocs()
for i := 0; i < bench.N; i++ {
b2.Set(uint(rand.Int31()))
}
})
}