MCPcopy
hub / github.com/assetnote/kiterunner / BenchmarkMemoryRequest

Function BenchmarkMemoryRequest

pkg/http/client_benchmark_test.go:137–167  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

135}
136
137func BenchmarkMemoryRequest(b *testing.B) {
138 b.ReportAllocs()
139 var (
140 memlist = memoryServer(b)
141 path = "/foo"
142 client = NewHTTPClient(memlist.Addr().String(), false)
143 hostname = strings.SplitN(memlist.Addr().String(), ":", 2)[0]
144 port = 80
145 req = Request{Route: &Route{Path: []byte( path )}, Target: &Target{Hostname: hostname, Port: port}}
146 config = Config{
147 Timeout: 1 * time.Second,
148 ReadHeaders: false,
149 ReadBody: false,
150 }
151 )
152 defer memlist.Close()
153 client.Dial = func(addr string) (net.Conn, error) {
154 return memlist.Dial()
155 }
156 client.ReadTimeout = 10 * time.Millisecond
157 client.WriteTimeout = 10 * time.Millisecond
158
159 var err error
160 for i := 0; i < b.N; i++ {
161 _, err = DoClient(client, req, &config)
162 if err != nil {
163 b.Fatalf("bad %v", err)
164 }
165 }
166 _ = err
167}
168
169func BenchmarkMemoryRedirectRequest(b *testing.B) {
170 log.SetLevelString("error")

Callers

nothing calls this directly

Calls 4

memoryServerFunction · 0.85
NewHTTPClientFunction · 0.85
DoClientFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected