From f9cc8530fb865c4136c77cce9920bbc14b613df2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 13 Mar 2024 23:30:18 +0100 Subject: [PATCH] Added pat --- README.md | 2 ++ web/go.mod | 1 + web/go.sum | 2 ++ web/pat_test.go | 22 ++++++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 web/pat_test.go diff --git a/README.md b/README.md index 0afc52c..15ac619 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ BenchmarkEcho/Hello-12 19503808 51.41 ns/op BenchmarkEcho/GitHub-12 10899865 110.8 ns/op 0 B/op 0 allocs/op BenchmarkGin/Hello-12 21826857 52.77 ns/op 0 B/op 0 allocs/op BenchmarkGin/GitHub-12 11601283 101.9 ns/op 0 B/op 0 allocs/op +BenchmarkPat/Hello-12 14964374 78.41 ns/op 48 B/op 1 allocs/op +BenchmarkPat/GitHub-12 20892 83599 ns/op 374765 B/op 235 allocs/op BenchmarkWay/Hello-12 5323245 222.9 ns/op 307 B/op 3 allocs/op BenchmarkWay/GitHub-12 114187 9397 ns/op 4979 B/op 177 allocs/op ``` \ No newline at end of file diff --git a/web/go.mod b/web/go.mod index 3ffa7b4..ccfddc7 100644 --- a/web/go.mod +++ b/web/go.mod @@ -6,6 +6,7 @@ require ( git.akyoto.dev/go/router v0.1.3 git.akyoto.dev/go/server v0.0.0-20240313191801-c13dbc55d263 github.com/beego/beego/v2 v2.1.6 + github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f github.com/gin-gonic/gin v1.9.1 github.com/go-chi/chi/v5 v5.0.12 github.com/labstack/echo/v4 v4.11.4 diff --git a/web/go.sum b/web/go.sum index 04234e1..d3baf1c 100644 --- a/web/go.sum +++ b/web/go.sum @@ -8,6 +8,8 @@ github.com/beego/beego/v2 v2.1.6 h1:ny2WqvtpG1gAkEqJ9PQrOz6ZcQvVBJK+dECDOd/heIM= github.com/beego/beego/v2 v2.1.6/go.mod h1:kFJvA21OjBwixXKx7BeH+Ug492Pp+h4cORHFTf1L8e0= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f h1:gOO/tNZMjjvTKZWpY7YnXC72ULNLErRtp94LountVE8= +github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= diff --git a/web/pat_test.go b/web/pat_test.go new file mode 100644 index 0000000..a11d33c --- /dev/null +++ b/web/pat_test.go @@ -0,0 +1,22 @@ +package main_test + +import ( + "net/http" + "testing" + + "github.com/bmizerany/pat" +) + +func BenchmarkPat(b *testing.B) { + bench( + b, + func() *pat.PatternServeMux { + return pat.New() + }, + func(m *pat.PatternServeMux, method string, path string) { + m.Add(method, path, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Write(payload) + })) + }, + ) +}