File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,60 +6,48 @@ import "testing"
66const nw = 1 << 10
77
88func BenchmarkSize (b * testing.B ) {
9- b .StopTimer ()
109 s := BuildTestSet (nw << 3 ) // Allocates nw<<3 bytes = nw words.
11- b .StartTimer ()
12-
10+ b .ResetTimer ()
1311 for i := 0 ; i < b .N / nw ; i ++ { // Measure time per word.
1412 s .Size ()
1513 }
1614}
1715
1816func BenchmarkNext (b * testing.B ) {
19- b .StopTimer ()
2017 s := BuildTestSet (b .N )
21- b .StartTimer ()
22-
18+ b .ResetTimer ()
2319 for n := - 2 ; n != - 1 ; {
2420 n = s .Next (n )
2521 }
2622}
2723
2824func BenchmarkPrev (b * testing.B ) {
29- b .StopTimer ()
3025 s := BuildTestSet (b .N )
31- b .StartTimer ()
32-
26+ b .ResetTimer ()
3327 for n := MaxInt ; n != - 1 ; {
3428 n = s .Prev (n )
3529 }
3630}
3731
3832func BenchmarkVisit (b * testing.B ) {
39- b .StopTimer ()
4033 s := BuildTestSet (b .N ) // As Visit is pretty fast, s can be pretty big.
41- b .StartTimer ()
42-
34+ b .ResetTimer ()
4335 s .Visit (func (n int ) (skip bool ) { return })
4436}
4537
4638func BenchmarkSetAnd (b * testing.B ) {
47- b .StopTimer ()
4839 s := New (64 * nw - 1 ).Delete (64 * nw - 1 ) // Allocates nw words.
4940 s1 := BuildTestSet (nw << 3 )
5041 s2 := BuildTestSet (nw << 3 )
51- b .StartTimer ()
52-
42+ b .ResetTimer ()
5343 for i := 0 ; i < b .N / nw ; i ++ { // Measure time per word.
5444 s .SetAnd (s1 , s2 )
5545 }
5646}
5747
5848func BenchmarkString (b * testing.B ) {
59- b .StopTimer ()
6049 s := BuildTestSet (b .N ) // As Visit is pretty fast, s can be pretty big.
61- b .StartTimer ()
62-
50+ b .ResetTimer ()
6351 _ = s .String ()
6452}
6553
You can’t perform that action at this time.
0 commit comments