aboutsummaryrefslogtreecommitdiff
path: root/server_timing_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-24 13:55:00 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-24 13:55:00 +0200
commit45ed91125118b4452074b02ea9052b1b8820c7f8 (patch)
tree2903a796a16f30acbf62b28ffe5e8f734e88d989 /server_timing_test.go
parentClose connection and release worker channel on panic in WorkerFunc (diff)
downloadfasthttp-45ed91125118b4452074b02ea9052b1b8820c7f8.tar.gz
fasthttp-45ed91125118b4452074b02ea9052b1b8820c7f8.tar.bz2
fasthttp-45ed91125118b4452074b02ea9052b1b8820c7f8.zip
Improved RequestCtx.Hijack() - now HijackHandler works with the real net.Conn instead of fake io.ReadWriter. Also reduced memory usage by releasing empty read buffers on hijacked connections
Diffstat (limited to 'server_timing_test.go')
-rw-r--r--server_timing_test.go24
1 files changed, 2 insertions, 22 deletions
diff --git a/server_timing_test.go b/server_timing_test.go
index 0859855..679208c 100644
--- a/server_timing_test.go
+++ b/server_timing_test.go
@@ -118,12 +118,9 @@ func BenchmarkServerHijack(b *testing.B) {
responseBody := []byte("123")
s := &Server{
Handler: func(ctx *RequestCtx) {
- ctx.Hijack(func(c io.ReadWriter) {
+ ctx.Hijack(func(c net.Conn) {
// emulate server loop :)
- conn := &fakeNetConn{
- c: c,
- }
- err := ServeConn(conn, func(ctx *RequestCtx) {
+ err := ServeConn(c, func(ctx *RequestCtx) {
ctx.Success("foobar", responseBody)
registerServedRequest(b, ch)
})
@@ -141,23 +138,6 @@ func BenchmarkServerHijack(b *testing.B) {
verifyRequestsServed(b, ch)
}
-type fakeNetConn struct {
- net.Conn
- c io.ReadWriter
-}
-
-func (c *fakeNetConn) Read(p []byte) (int, error) {
- return c.c.Read(p)
-}
-
-func (c *fakeNetConn) Write(p []byte) (int, error) {
- return c.c.Write(p)
-}
-
-func (c *fakeNetConn) Close() error {
- return nil
-}
-
func BenchmarkServerMaxConnsPerIP(b *testing.B) {
clientsCount := 1000
requestsPerConn := 10