diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-15 23:47:22 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-15 23:47:22 +0200 |
commit | f1f78f0828ead1f1e97d7506d1cda3d21077632a (patch) | |
tree | 329bd48407f9cca99c7c7283806e8ef5992751cf /uri_timing_test.go | |
parent | Added DoTimeout() to client (diff) | |
download | fasthttp-f1f78f0828ead1f1e97d7506d1cda3d21077632a.tar.gz fasthttp-f1f78f0828ead1f1e97d7506d1cda3d21077632a.tar.bz2 fasthttp-f1f78f0828ead1f1e97d7506d1cda3d21077632a.zip |
Hide Request.URI and Request.PostArgs behind accessors, which automatically call parse URI and PostArgs on first access
Diffstat (limited to 'uri_timing_test.go')
-rw-r--r-- | uri_timing_test.go | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/uri_timing_test.go b/uri_timing_test.go index 79e146b..44a1d29 100644 --- a/uri_timing_test.go +++ b/uri_timing_test.go @@ -20,13 +20,30 @@ func BenchmarkURIParseHostname(b *testing.B) { benchmarkURIParse(b, "google.com", "http://foobar.com/foo/bar?query=string&other=value#hashstring") } +func BenchmarkURIFullURI(b *testing.B) { + host := []byte("foobar.com") + requestURI := []byte("/foobar/baz?aaa=bbb&ccc=ddd") + uriLen := len(host) + len(requestURI) + 7 + + b.RunParallel(func(pb *testing.PB) { + var u URI + u.Parse(host, requestURI) + for pb.Next() { + uri := u.FullURI() + if len(uri) != uriLen { + b.Fatalf("unexpected uri len %d. Expecting %d", len(uri), uriLen) + } + } + }) +} + func benchmarkURIParse(b *testing.B, host, uri string) { strHost, strURI := []byte(host), []byte(uri) b.RunParallel(func(pb *testing.PB) { - var uri URI + var u URI for pb.Next() { - uri.Parse(strHost, strURI) + u.Parse(strHost, strURI) } }) } |