aboutsummaryrefslogtreecommitdiff
path: root/client_timing_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-03-01 01:11:20 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-03-01 01:11:20 +0200
commita19a1965951d0cb627800a126b0eb94c0cca3cf6 (patch)
treefeb02ca9386bf8c7be2f303d6879679f3e7e41f8 /client_timing_test.go
parentSet timeout when benchmarking big responses (diff)
downloadfasthttp-a19a1965951d0cb627800a126b0eb94c0cca3cf6.tar.gz
fasthttp-a19a1965951d0cb627800a126b0eb94c0cca3cf6.tar.bz2
fasthttp-a19a1965951d0cb627800a126b0eb94c0cca3cf6.zip
Use DoTimeout instead of GetTimeout in 'big response' benchmark
Diffstat (limited to 'client_timing_test.go')
-rw-r--r--client_timing_test.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/client_timing_test.go b/client_timing_test.go
index f885487..25c0264 100644
--- a/client_timing_test.go
+++ b/client_timing_test.go
@@ -462,19 +462,20 @@ func benchmarkClientEndToEndBigResponseInmemory(b *testing.B, parallelism int) {
url := "http://unused.host" + requestURI
b.SetParallelism(parallelism)
b.RunParallel(func(pb *testing.PB) {
- var buf []byte
+ var req Request
+ req.SetRequestURI(url)
+ var resp Response
for pb.Next() {
- statusCode, body, err := c.GetTimeout(buf, url, time.Second)
- if err != nil {
+ if err := c.DoTimeout(&req, &resp, 5*time.Second); err != nil {
b.Fatalf("unexpected error: %s", err)
}
- if statusCode != StatusOK {
- b.Fatalf("unexpected status code: %d. Expecting %d", statusCode, StatusOK)
+ if resp.StatusCode() != StatusOK {
+ b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode(), StatusOK)
}
+ body := resp.Body()
if !bytes.Equal(bigResponse, body) {
b.Fatalf("unexpected response %q. Expecting %q", body, bigResponse)
}
- buf = body
}
})
@@ -516,15 +517,19 @@ func benchmarkNetHTTPClientEndToEndBigResponseInmemory(b *testing.B, parallelism
Dial: func(_, _ string) (net.Conn, error) { return ln.Dial() },
MaxIdleConnsPerHost: parallelism * runtime.GOMAXPROCS(-1),
},
- Timeout: time.Second,
+ Timeout: 5*time.Second,
}
requestURI := "/foo/bar?baz=123"
url := "http://unused.host" + requestURI
b.SetParallelism(parallelism)
b.RunParallel(func(pb *testing.PB) {
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ b.Fatalf("unexpected error: %s", err)
+ }
for pb.Next() {
- resp, err := c.Get(url)
+ resp, err := c.Do(req)
if err != nil {
b.Fatalf("unexpected error: %s", err)
}