-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbench_test.go
More file actions
107 lines (100 loc) · 1.75 KB
/
bench_test.go
File metadata and controls
107 lines (100 loc) · 1.75 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Written by http://xojoc.pw. Public Domain.
package bitset
import (
"math/big"
"testing"
)
func Benchmark(b *testing.B) {
}
func BenchmarkClone(b *testing.B) {
s := &BitSet{}
s.Set(1000 * 100 * 1000)
for n := 0; n < b.N; n++ {
n := s.Clone()
n.Get(0)
}
}
func BenchmarkSet(b *testing.B) {
len := 1000
s := &BitSet{}
for n := 0; n < b.N; n++ {
for i := 0; i < len; i++ {
s.Set(i)
}
}
}
func BenchmarkSetBig(b *testing.B) {
len := 1000
s := big.NewInt(0)
for n := 0; n < b.N; n++ {
for i := 0; i < len; i++ {
s.SetBit(s, i, 1)
}
}
}
func BenchmarkSetHigh(b *testing.B) {
s := &BitSet{}
i := 1
for n := 0; n < b.N; n++ {
s.Set(100 * 1000 * 1000 * i)
i++
}
}
func BenchmarkSetRange(b *testing.B) {
s := &BitSet{}
s.SetRange(0, 100*1000*1000)
}
func BenchmarkClearRange(b *testing.B) {
s := &BitSet{}
s.SetRange(0, 100*1000*1000)
s.ClearRange(0, 100*1000*1000)
}
func BenchmarkToggleRange(b *testing.B) {
s := &BitSet{}
s.SetRange(50*1000*1000, 100*1000*1000)
s.ToggleRange(0, 100*1000*1000)
}
func BenchmarkGetEmpty(b *testing.B) {
s := &BitSet{}
len := 1000 * 1000
for n := 0; n < b.N; n++ {
for i := 0; i < len; i++ {
s.Get(i)
}
}
}
func BenchmarkGetEmptyBig(b *testing.B) {
s := big.NewInt(0)
len := 1000 * 1000
s.SetBit(s, len-1, 1)
for n := 0; n < b.N; n++ {
for i := 0; i < len; i++ {
s.Bit(i)
}
}
}
/*
func BenchmarkUnion(b *testing.B) {
a := New(1000)
c := New(1000)
for n := 0; n < b.N; n++ {
a.Union(c)
}
}
func BenchmarkUnionBig(b *testing.B) {
len := 1000
a := big.NewInt(0)
a.SetBit(a, len-1, 1)
c := big.NewInt(0)
c.SetBit(c, len-1, 1)
for n := 0; n < b.N; n++ {
a.Or(a, c)
}
}
func BenchmarkString(b *testing.B) {
a := New(100000)
for n := 0; n < b.N; n++ {
_ = a.String()
}
}
*/