Alanxtl commented on code in PR #3399:
URL: https://github.com/apache/dubbo-go/pull/3399#discussion_r3394567949


##########
common/url_benchmark_test.go:
##########
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package common
+
+import (
+       "fmt"
+       "net/url"
+       "testing"
+)
+
+import (
+       gxset "github.com/dubbogo/gost/container/set"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+)
+
+const (
+       benchmarkURLProtocol  = "dubbo"
+       benchmarkURLIP        = "127.0.0.1"
+       benchmarkURLPort      = "20000"
+       benchmarkURLInterface = "com.test.BenchmarkService"
+       benchmarkURLGroup     = "benchmark"
+       benchmarkURLVersion   = "1.0.0"
+       benchmarkURLTimestamp = "1234567890"
+       benchmarkURLMeshID    = "benchmark-mesh"
+)
+
+var (
+       benchmarkURLParamSizes = []int{1, 32, 256, 1024}
+
+       benchmarkURLStringSink string
+       benchmarkURLSink       *URL
+       benchmarkURLParamsSink url.Values
+       benchmarkURLMapSink    map[string]string
+       benchmarkURLBoolSink   bool
+)
+
+func BenchmarkURLString(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.String()
+       })
+}
+
+func BenchmarkURLKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.Key()
+       })
+}
+
+func BenchmarkURLGetCacheInvokerMapKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.GetCacheInvokerMapKey()
+       })
+}
+
+func BenchmarkURLServiceKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.ServiceKey()
+       })
+}
+
+func BenchmarkURLCopyParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.CopyParams()
+       })
+}
+
+func BenchmarkURLGetParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.GetParams()
+       })
+}
+
+func BenchmarkURLClone(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.Clone()
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_suburl", paramCount), func(b 
*testing.B) {
+                       u := makeBenchmarkURLWithSubURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.Clone()
+                       }
+               })
+       }
+}
+
+func BenchmarkURLCloneWithFilter(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.CloneWithFilter(nil, nil)
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_exclude_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       excludeParams := makeBenchmarkExcludeSet(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = 
u.CloneWithFilter(excludeParams, nil)
+                       }
+               })
+       }
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_reserve_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       reserveParams := makeBenchmarkReserveKeys(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.CloneWithFilter(nil, 
reserveParams)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLMergeURL(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_method_params", paramCount), 
func(b *testing.B) {
+                       left, right := 
makeBenchmarkMergeHalfOverlapPair(paramCount)
+                       addBenchmarkMethodParams(right)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = left.MergeURL(right)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLToMap(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLMapSink = u.ToMap()
+       })
+}
+
+func BenchmarkURLIsEquals(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       left := makeBenchmarkURL(paramCount)
+                       right := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLBoolSink = IsEquals(left, right)
+                       }
+               })
+       }
+}
+
+func runBenchmarkURLByParamSize(b *testing.B, run func(*URL)) {
+       b.Helper()
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               run(u)
+                       }
+               })
+       }
+}
+
+func makeBenchmarkURL(paramCount int) *URL {
+       return makeBenchmarkURLWithParamStart(paramCount, 0)
+}
+
+func makeBenchmarkURLWithSubURL(paramCount int) *URL {
+       u := makeBenchmarkURL(paramCount)
+       u.SubURL = makeBenchmarkURL(paramCount)
+       return u
+}
+
+func makeBenchmarkURLWithParamStart(paramCount int, genericStart int) *URL {
+       u := NewURLWithOptions(
+               WithProtocol(benchmarkURLProtocol),
+               WithIp(benchmarkURLIP),
+               WithPort(benchmarkURLPort),
+               WithPath(benchmarkURLInterface),
+               WithMethods(makeBenchmarkMethods()),
+               WithParams(makeBenchmarkParams(paramCount, genericStart)),
+       )
+       u.primitiveTS = u.GetParam(constant.TimestampKey, "")
+       return u
+}
+
+func makeBenchmarkMergeHalfOverlapPair(paramCount int) (*URL, *URL) {
+       genericCount := paramCount - len(benchmarkURLIdentityParams)
+       if genericCount < 0 {
+               genericCount = 0
+       }
+       return makeBenchmarkURL(paramCount), 
makeBenchmarkURLWithParamStart(paramCount, genericCount/2)
+}
+
+func makeBenchmarkParams(paramCount int, genericStart int) url.Values {

Review Comment:
   ```suggestion
   func makeBenchmarkParams(paramCount, genericStart int) url.Values {
   ```



##########
common/url_benchmark_test.go:
##########
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package common
+
+import (
+       "fmt"
+       "net/url"
+       "testing"
+)
+
+import (
+       gxset "github.com/dubbogo/gost/container/set"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+)
+
+const (
+       benchmarkURLProtocol  = "dubbo"
+       benchmarkURLIP        = "127.0.0.1"
+       benchmarkURLPort      = "20000"
+       benchmarkURLInterface = "com.test.BenchmarkService"
+       benchmarkURLGroup     = "benchmark"
+       benchmarkURLVersion   = "1.0.0"
+       benchmarkURLTimestamp = "1234567890"
+       benchmarkURLMeshID    = "benchmark-mesh"
+)
+
+var (
+       benchmarkURLParamSizes = []int{1, 32, 256, 1024}
+
+       benchmarkURLStringSink string
+       benchmarkURLSink       *URL
+       benchmarkURLParamsSink url.Values
+       benchmarkURLMapSink    map[string]string
+       benchmarkURLBoolSink   bool
+)
+
+func BenchmarkURLString(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.String()
+       })
+}
+
+func BenchmarkURLKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.Key()
+       })
+}
+
+func BenchmarkURLGetCacheInvokerMapKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.GetCacheInvokerMapKey()
+       })
+}
+
+func BenchmarkURLServiceKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.ServiceKey()
+       })
+}
+
+func BenchmarkURLCopyParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.CopyParams()
+       })
+}
+
+func BenchmarkURLGetParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.GetParams()
+       })
+}
+
+func BenchmarkURLClone(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.Clone()
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_suburl", paramCount), func(b 
*testing.B) {
+                       u := makeBenchmarkURLWithSubURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.Clone()
+                       }
+               })
+       }
+}
+
+func BenchmarkURLCloneWithFilter(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.CloneWithFilter(nil, nil)
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_exclude_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       excludeParams := makeBenchmarkExcludeSet(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = 
u.CloneWithFilter(excludeParams, nil)
+                       }
+               })
+       }
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_reserve_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       reserveParams := makeBenchmarkReserveKeys(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.CloneWithFilter(nil, 
reserveParams)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLMergeURL(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_method_params", paramCount), 
func(b *testing.B) {
+                       left, right := 
makeBenchmarkMergeHalfOverlapPair(paramCount)
+                       addBenchmarkMethodParams(right)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = left.MergeURL(right)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLToMap(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLMapSink = u.ToMap()
+       })
+}
+
+func BenchmarkURLIsEquals(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       left := makeBenchmarkURL(paramCount)
+                       right := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLBoolSink = IsEquals(left, right)
+                       }
+               })
+       }
+}
+
+func runBenchmarkURLByParamSize(b *testing.B, run func(*URL)) {
+       b.Helper()
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               run(u)
+                       }
+               })
+       }
+}
+
+func makeBenchmarkURL(paramCount int) *URL {
+       return makeBenchmarkURLWithParamStart(paramCount, 0)
+}
+
+func makeBenchmarkURLWithSubURL(paramCount int) *URL {
+       u := makeBenchmarkURL(paramCount)
+       u.SubURL = makeBenchmarkURL(paramCount)
+       return u
+}
+
+func makeBenchmarkURLWithParamStart(paramCount int, genericStart int) *URL {
+       u := NewURLWithOptions(
+               WithProtocol(benchmarkURLProtocol),
+               WithIp(benchmarkURLIP),
+               WithPort(benchmarkURLPort),
+               WithPath(benchmarkURLInterface),
+               WithMethods(makeBenchmarkMethods()),
+               WithParams(makeBenchmarkParams(paramCount, genericStart)),
+       )
+       u.primitiveTS = u.GetParam(constant.TimestampKey, "")
+       return u
+}
+
+func makeBenchmarkMergeHalfOverlapPair(paramCount int) (*URL, *URL) {
+       genericCount := paramCount - len(benchmarkURLIdentityParams)
+       if genericCount < 0 {
+               genericCount = 0
+       }
+       return makeBenchmarkURL(paramCount), 
makeBenchmarkURLWithParamStart(paramCount, genericCount/2)
+}
+
+func makeBenchmarkParams(paramCount int, genericStart int) url.Values {
+       params := make(url.Values, paramCount)
+       for i, param := range benchmarkURLIdentityParams {
+               if i >= paramCount {
+                       return params
+               }
+               params.Set(param.key, param.value)
+       }
+       for i := len(benchmarkURLIdentityParams); i < paramCount; i++ {
+               genericIndex := genericStart + i - 
len(benchmarkURLIdentityParams)
+               params.Set(fmt.Sprintf("key%d", genericIndex), 
fmt.Sprintf("value%d", genericIndex))
+       }
+       return params
+}

Review Comment:
   benchmark 维度有点误导
   
     `makeBenchmarkParams(paramCount, ...)` 把 `paramCount` 当成“总参数数”。所以 
`params_1` 只包含 `interface`,但没有 `group/version/timestamp/meshClusterID`;而 
`params_32+` 才包含完整 identity params。这样 
`BenchmarkURLServiceKey`、`BenchmarkURLKey`、`BenchmarkURLGetCacheInvokerMapKey` 
的 `params_1` 和其它 tier 测的不是同一种语义 URL,后续看趋势时容易误判“参数量影响”。建议始终保留 identity params,把 
`1/32/256/1024` 定义成额外 generic 参数数,或者把 case 命名成 `total_params_N` 并单独加完整 identity 
的小参数 case。



##########
common/url_benchmark_test.go:
##########
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package common
+
+import (
+       "fmt"
+       "net/url"
+       "testing"
+)
+
+import (
+       gxset "github.com/dubbogo/gost/container/set"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+)
+
+const (
+       benchmarkURLProtocol  = "dubbo"
+       benchmarkURLIP        = "127.0.0.1"
+       benchmarkURLPort      = "20000"
+       benchmarkURLInterface = "com.test.BenchmarkService"
+       benchmarkURLGroup     = "benchmark"
+       benchmarkURLVersion   = "1.0.0"
+       benchmarkURLTimestamp = "1234567890"
+       benchmarkURLMeshID    = "benchmark-mesh"
+)
+
+var (
+       benchmarkURLParamSizes = []int{1, 32, 256, 1024}
+
+       benchmarkURLStringSink string
+       benchmarkURLSink       *URL
+       benchmarkURLParamsSink url.Values
+       benchmarkURLMapSink    map[string]string
+       benchmarkURLBoolSink   bool
+)
+
+func BenchmarkURLString(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.String()
+       })
+}
+
+func BenchmarkURLKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.Key()
+       })
+}
+
+func BenchmarkURLGetCacheInvokerMapKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.GetCacheInvokerMapKey()
+       })
+}
+
+func BenchmarkURLServiceKey(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLStringSink = u.ServiceKey()
+       })
+}
+
+func BenchmarkURLCopyParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.CopyParams()
+       })
+}
+
+func BenchmarkURLGetParams(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLParamsSink = u.GetParams()
+       })
+}
+
+func BenchmarkURLClone(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.Clone()
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_suburl", paramCount), func(b 
*testing.B) {
+                       u := makeBenchmarkURLWithSubURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.Clone()
+                       }
+               })
+       }
+}
+
+func BenchmarkURLCloneWithFilter(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLSink = u.CloneWithFilter(nil, nil)
+       })
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_exclude_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       excludeParams := makeBenchmarkExcludeSet(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = 
u.CloneWithFilter(excludeParams, nil)
+                       }
+               })
+       }
+
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_reserve_20_percent", paramCount), 
func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       reserveParams := makeBenchmarkReserveKeys(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = u.CloneWithFilter(nil, 
reserveParams)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLMergeURL(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d_with_method_params", paramCount), 
func(b *testing.B) {
+                       left, right := 
makeBenchmarkMergeHalfOverlapPair(paramCount)
+                       addBenchmarkMethodParams(right)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLSink = left.MergeURL(right)
+                       }
+               })
+       }
+}
+
+func BenchmarkURLToMap(b *testing.B) {
+       runBenchmarkURLByParamSize(b, func(u *URL) {
+               benchmarkURLMapSink = u.ToMap()
+       })
+}
+
+func BenchmarkURLIsEquals(b *testing.B) {
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       left := makeBenchmarkURL(paramCount)
+                       right := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               benchmarkURLBoolSink = IsEquals(left, right)
+                       }
+               })
+       }
+}
+
+func runBenchmarkURLByParamSize(b *testing.B, run func(*URL)) {
+       b.Helper()
+       for _, paramCount := range benchmarkURLParamSizes {
+               paramCount := paramCount
+               b.Run(fmt.Sprintf("params_%d", paramCount), func(b *testing.B) {
+                       u := makeBenchmarkURL(paramCount)
+                       b.ReportAllocs()
+                       b.ResetTimer()
+                       for i := 0; i < b.N; i++ {
+                               run(u)
+                       }
+               })
+       }
+}
+
+func makeBenchmarkURL(paramCount int) *URL {
+       return makeBenchmarkURLWithParamStart(paramCount, 0)
+}
+
+func makeBenchmarkURLWithSubURL(paramCount int) *URL {
+       u := makeBenchmarkURL(paramCount)
+       u.SubURL = makeBenchmarkURL(paramCount)
+       return u
+}
+
+func makeBenchmarkURLWithParamStart(paramCount int, genericStart int) *URL {

Review Comment:
   ```suggestion
   func makeBenchmarkURLWithParamStart(paramCount, genericStart int) *URL {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to