Added pat

This commit is contained in:
Eduard Urbach 2024-03-13 23:30:18 +01:00
parent 2e9daf9a78
commit f9cc8530fb
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
4 changed files with 27 additions and 0 deletions

View File

@ -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
```

View File

@ -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

View File

@ -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=

22
web/pat_test.go Normal file
View File

@ -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)
}))
},
)
}