diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-17 11:47:38 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-17 11:47:38 +0200 |
commit | 0d9c2f38b0df813b62114aa22e95cc07c17ab446 (patch) | |
tree | 22bccf289a69da9c338f059cdf6e30a56c19b6c8 /server_timing_test.go | |
parent | Server microoptimization: check response's 'connection: close' first (diff) | |
download | fasthttp-0d9c2f38b0df813b62114aa22e95cc07c17ab446.tar.gz fasthttp-0d9c2f38b0df813b62114aa22e95cc07c17ab446.tar.bz2 fasthttp-0d9c2f38b0df813b62114aa22e95cc07c17ab446.zip |
Move response body creation outside hot path in server benchmarks
Diffstat (limited to 'server_timing_test.go')
-rw-r--r-- | server_timing_test.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server_timing_test.go b/server_timing_test.go index a1904a5..58ae4b0 100644 --- a/server_timing_test.go +++ b/server_timing_test.go @@ -115,9 +115,10 @@ func BenchmarkServerMaxConnsPerIP(b *testing.B) { clientsCount := 1000 requestsPerConn := 10 ch := make(chan struct{}, b.N) + responseBody := []byte("123") s := &Server{ Handler: func(ctx *RequestCtx) { - ctx.Success("foobar", []byte("123")) + ctx.Success("foobar", responseBody) registerServedRequest(b, ch) }, MaxConnsPerIP: clientsCount * 2, @@ -133,15 +134,16 @@ func BenchmarkServerTimeoutError(b *testing.B) { requestsPerConn := 10 ch := make(chan struct{}, b.N) n := uint32(0) + responseBody := []byte("123") s := &Server{ Handler: func(ctx *RequestCtx) { if atomic.AddUint32(&n, 1)&7 == 0 { ctx.TimeoutError("xxx") go func() { - ctx.Success("foobar", []byte("123")) + ctx.Success("foobar", responseBody) }() } else { - ctx.Success("foobar", []byte("123")) + ctx.Success("foobar", responseBody) } registerServedRequest(b, ch) }, |