@@ -156,22 +156,17 @@ func BenchmarkHTrieMatch(b *testing.B) {
156156 "|s|example.org|i|*/test.png" ,
157157 }
158158
159- testURLin := []string {
159+ testURLs := []string {
160160 "http://example.com/foo/test.png" ,
161161 "http://bar.example.com/foo/test.png" ,
162162 "http://bar.example.com/foo/testx.png" ,
163163 "http://bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/test.png" ,
164164 "http://bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/testx.png" ,
165+ // this one kills the regex pretty bad.
166+ "bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/testx.png" ,
165167 }
166168
167- var (
168- testIters = 10
169- testURLSize = 10000
170- )
171- testURLs := make ([]string , 0 )
172- for i := 0 ; i < testURLSize ; i ++ {
173- testURLs = append (testURLs , testURLin [i % 3 ])
174- }
169+ testIters := 10000
175170
176171 dt := NewURLMatcher ()
177172 for _ , rule := range rules {
@@ -183,7 +178,6 @@ func BenchmarkHTrieMatch(b *testing.B) {
183178 for _ , u := range testURLs {
184179 u , _ := url .Parse (u )
185180 parsed = append (parsed , u )
186-
187181 }
188182
189183 // avoid inlining optimization
@@ -200,30 +194,26 @@ func BenchmarkHTrieMatch(b *testing.B) {
200194
201195func BenchmarkRegexMatch (b * testing.B ) {
202196 rules := []string {
203- `^foo.example.net/test.png` ,
197+ // giving regex lots of help here, putting this rule first
198+ `^.*\.example.com/.*/test.png` ,
204199 `^bar.example.net/test.png` ,
200+ `^foo.example.net/test.png` ,
205201 `^.*\.bar.example.net/test.png` ,
206202 `^.*\.hodor.example.net/.*/test.png` ,
207- `^.*\.example.com/.*/test.png` ,
208203 `^(.*\.)?example.org/(?:i.*/test.png)` ,
209204 }
210205
211- testURLin := []string {
206+ testURLs := []string {
212207 "example.com/foo/test.png" ,
213208 "bar.example.com/foo/test.png" ,
214209 "bar.example.com/foo/testx.png" ,
215210 "bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/test.png" ,
216211 "bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/testx.png" ,
212+ // this one kills the regex pretty bad. :(
213+ //"bar.example.com/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/testx.png",
217214 }
218215
219- var (
220- testIters = 10
221- testURLSize = 10000
222- )
223- testURLs := make ([]string , 0 )
224- for i := 0 ; i < testURLSize ; i ++ {
225- testURLs = append (testURLs , testURLin [i % 3 ])
226- }
216+ testIters := 10000
227217
228218 rexes := make ([]* regexp.Regexp , 0 )
229219 for _ , r := range rules {
0 commit comments