MCPcopy Index your code
hub / github.com/gobwas/ws / BenchmarkHttpWriteUpgradeRequest

Function BenchmarkHttpWriteUpgradeRequest

http_test.go:96–135  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

94}
95
96func BenchmarkHttpWriteUpgradeRequest(b *testing.B) {
97 for _, test := range []struct {
98 url *url.URL
99 protocols []string
100 extensions []httphead.Option
101 headers HandshakeHeaderFunc
102 host string
103 }{
104 {
105 url: makeURL("ws://example.org"),
106 },
107 {
108 url: makeURL("ws://example.org"),
109 host: "test-host",
110 },
111 } {
112 bw := bufio.NewWriter(ioutil.Discard)
113 nonce := make([]byte, nonceSize)
114 initNonce(nonce)
115
116 var headers HandshakeHeader
117 if test.headers != nil {
118 headers = test.headers
119 }
120
121 b.ResetTimer()
122 b.Run("", func(b *testing.B) {
123 for i := 0; i < b.N; i++ {
124 httpWriteUpgradeRequest(bw,
125 test.url,
126 nonce,
127 test.protocols,
128 test.extensions,
129 headers,
130 test.host,
131 )
132 }
133 })
134 }
135}
136
137func makeURL(s string) *url.URL {
138 ret, err := url.Parse(s)

Callers

nothing calls this directly

Calls 3

initNonceFunction · 0.85
httpWriteUpgradeRequestFunction · 0.85
makeURLFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…