(b *testing.B)
| 135 | } |
| 136 | |
| 137 | func 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 | |
| 169 | func BenchmarkMemoryRedirectRequest(b *testing.B) { |
| 170 | log.SetLevelString("error") |
nothing calls this directly
no test coverage detected