Skip to content

Commit 28c93a7

Browse files
committed
net/url: add benchmarks for Encode
1 parent a5f55a4 commit 28c93a7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/net/url/url_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,17 @@ var encodeQueryTests = []EncodeQueryTest{
11081108
"b": {"b1", "b2", "b3"},
11091109
"c": {"c1", "c2", "c3"},
11101110
}, "a=a1&a=a2&a=a3&b=b1&b=b2&b=b3&c=c1&c=c2&c=c3"},
1111+
{Values{
1112+
"a": {"a"},
1113+
"b": {"b"},
1114+
"c": {"c"},
1115+
"d": {"d"},
1116+
"e": {"e"},
1117+
"f": {"f"},
1118+
"g": {"g"},
1119+
"h": {"h"},
1120+
"i": {"i"},
1121+
}, "a=a&b=b&c=c&d=d&e=e&f=f&g=g&h=h&i=i"},
11111122
}
11121123

11131124
func TestEncodeQuery(t *testing.T) {
@@ -1118,6 +1129,17 @@ func TestEncodeQuery(t *testing.T) {
11181129
}
11191130
}
11201131

1132+
func BenchmarkEncodeQuery(b *testing.B) {
1133+
for _, tt := range encodeQueryTests {
1134+
b.Run(tt.expected, func(b *testing.B) {
1135+
b.ReportAllocs()
1136+
for b.Loop() {
1137+
tt.m.Encode()
1138+
}
1139+
})
1140+
}
1141+
}
1142+
11211143
var resolvePathTests = []struct {
11221144
base, ref, expected string
11231145
}{

0 commit comments

Comments
 (0)