aboutsummaryrefslogtreecommitdiff
path: root/uri_timing_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-10-19 01:21:09 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-10-19 01:21:09 +0300
commita049630bca2089ac5ade886b2ea5554f65f065d3 (patch)
treed3156cf552338e101108988bce94cd6438742d38 /uri_timing_test.go
downloadfasthttp-a049630bca2089ac5ade886b2ea5554f65f065d3.tar.gz
fasthttp-a049630bca2089ac5ade886b2ea5554f65f065d3.tar.bz2
fasthttp-a049630bca2089ac5ade886b2ea5554f65f065d3.zip
initial commit
Diffstat (limited to 'uri_timing_test.go')
-rw-r--r--uri_timing_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/uri_timing_test.go b/uri_timing_test.go
new file mode 100644
index 0000000..79e146b
--- /dev/null
+++ b/uri_timing_test.go
@@ -0,0 +1,32 @@
+package fasthttp
+
+import (
+ "testing"
+)
+
+func BenchmarkURIParsePath(b *testing.B) {
+ benchmarkURIParse(b, "google.com", "/foo/bar")
+}
+
+func BenchmarkURIParsePathQueryString(b *testing.B) {
+ benchmarkURIParse(b, "google.com", "/foo/bar?query=string&other=value")
+}
+
+func BenchmarkURIParsePathQueryStringHash(b *testing.B) {
+ benchmarkURIParse(b, "google.com", "/foo/bar?query=string&other=value#hashstring")
+}
+
+func BenchmarkURIParseHostname(b *testing.B) {
+ benchmarkURIParse(b, "google.com", "http://foobar.com/foo/bar?query=string&other=value#hashstring")
+}
+
+func benchmarkURIParse(b *testing.B, host, uri string) {
+ strHost, strURI := []byte(host), []byte(uri)
+
+ b.RunParallel(func(pb *testing.PB) {
+ var uri URI
+ for pb.Next() {
+ uri.Parse(strHost, strURI)
+ }
+ })
+}