@@ -44,6 +44,7 @@ var randomPathMaker = randomPathAlphabet(MakePathOrDie(
44
44
"aac" ,
45
45
"aad" ,
46
46
"aae" ,
47
+ "aaf" ,
47
48
KeyByFields ("name" , value .StringValue ("first" )),
48
49
KeyByFields ("name" , value .StringValue ("second" )),
49
50
KeyByFields ("port" , value .IntValue (443 ), "protocol" , value .StringValue ("tcp" )),
@@ -63,7 +64,7 @@ func BenchmarkFieldSet(b *testing.B) {
63
64
minPathLen int
64
65
maxPathLen int
65
66
}{
66
- {10 , 1 , 2 },
67
+ // {10, 1, 2},
67
68
{20 , 2 , 3 },
68
69
{50 , 2 , 4 },
69
70
{100 , 3 , 6 },
@@ -79,6 +80,11 @@ func BenchmarkFieldSet(b *testing.B) {
79
80
}
80
81
return x
81
82
}
83
+ operands := make ([]* Set , 500 )
84
+ for i := range operands {
85
+ operands [i ] = makeSet ()
86
+ }
87
+ randOperand := func () * Set { return operands [rand .Intn (len (operands ))] }
82
88
83
89
b .Run (fmt .Sprintf ("insert-%v" , here .size ), func (b * testing.B ) {
84
90
b .ReportAllocs ()
@@ -87,35 +93,25 @@ func BenchmarkFieldSet(b *testing.B) {
87
93
}
88
94
})
89
95
b .Run (fmt .Sprintf ("has-%v" , here .size ), func (b * testing.B ) {
90
- x := makeSet ()
91
96
b .ReportAllocs ()
92
- b .ResetTimer ()
93
97
for i := 0 ; i < b .N ; i ++ {
94
- x .Has (randomPathMaker .makePath (here .minPathLen , here .maxPathLen ))
98
+ randOperand () .Has (randomPathMaker .makePath (here .minPathLen , here .maxPathLen ))
95
99
}
96
100
})
97
101
98
- operands := make ([]* Set , 50 )
99
- for i := range operands {
100
- operands [i ] = makeSet ()
101
- }
102
- randOperand := func () * Set { return operands [rand .Intn (len (operands ))] }
103
102
b .Run (fmt .Sprintf ("union-%v" , here .size ), func (b * testing.B ) {
104
- b .ResetTimer ()
105
103
b .ReportAllocs ()
106
104
for i := 0 ; i < b .N ; i ++ {
107
105
randOperand ().Union (randOperand ())
108
106
}
109
107
})
110
108
b .Run (fmt .Sprintf ("intersection-%v" , here .size ), func (b * testing.B ) {
111
- b .ResetTimer ()
112
109
b .ReportAllocs ()
113
110
for i := 0 ; i < b .N ; i ++ {
114
111
randOperand ().Intersection (randOperand ())
115
112
}
116
113
})
117
114
b .Run (fmt .Sprintf ("difference-%v" , here .size ), func (b * testing.B ) {
118
- b .ResetTimer ()
119
115
b .ReportAllocs ()
120
116
for i := 0 ; i < b .N ; i ++ {
121
117
randOperand ().Difference (randOperand ())
0 commit comments