Added aero and httprouter

This commit is contained in:
Eduard Urbach 2024-03-13 23:53:34 +01:00
parent 5099ba0019
commit d0ab09bf86
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
5 changed files with 109 additions and 16 deletions

View File

@ -3,20 +3,24 @@
## Web
```
BenchmarkAkyoto/Hello-12 29872866 38.33 ns/op 0 B/op 0 allocs/op
BenchmarkAkyoto/GitHub-12 15900098 72.91 ns/op 0 B/op 0 allocs/op
BenchmarkBeego/Hello-12 1000000 1089 ns/op 880 B/op 8 allocs/op
BenchmarkBeego/GitHub-12 722995 1654 ns/op 929 B/op 9 allocs/op
BenchmarkBone/Hello-12 42497811 26.97 ns/op 0 B/op 0 allocs/op
BenchmarkBone/GitHub-12 91179 12734 ns/op 4705 B/op 67 allocs/op
BenchmarkChi/Hello-12 4328472 275.4 ns/op 336 B/op 2 allocs/op
BenchmarkChi/GitHub-12 3447220 331.1 ns/op 336 B/op 2 allocs/op
BenchmarkEcho/Hello-12 19503808 51.41 ns/op 0 B/op 0 allocs/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
BenchmarkAero/Hello-12 27787401 43.49 ns/op 0 B/op 0 allocs/op
BenchmarkAero/GitHub-12 14898486 79.69 ns/op 0 B/op 0 allocs/op
BenchmarkAkyoto/Hello-12 31213448 38.58 ns/op 0 B/op 0 allocs/op
BenchmarkAkyoto/GitHub-12 15803650 73.84 ns/op 0 B/op 0 allocs/op
BenchmarkBeego/Hello-12 996962 1114 ns/op 880 B/op 8 allocs/op
BenchmarkBeego/GitHub-12 617126 1670 ns/op 929 B/op 9 allocs/op
BenchmarkBone/Hello-12 41957064 27.45 ns/op 0 B/op 0 allocs/op
BenchmarkBone/GitHub-12 98625 11877 ns/op 4705 B/op 67 allocs/op
BenchmarkChi/Hello-12 3913086 305.3 ns/op 336 B/op 2 allocs/op
BenchmarkChi/GitHub-12 3334267 360.1 ns/op 336 B/op 2 allocs/op
BenchmarkEcho/Hello-12 22774268 51.81 ns/op 0 B/op 0 allocs/op
BenchmarkEcho/GitHub-12 10904541 107.9 ns/op 0 B/op 0 allocs/op
BenchmarkGin/Hello-12 22575962 55.01 ns/op 0 B/op 0 allocs/op
BenchmarkGin/GitHub-12 12061074 99.05 ns/op 0 B/op 0 allocs/op
BenchmarkJSHR/Hello-12 56125498 20.89 ns/op 0 B/op 0 allocs/op
BenchmarkJSHR/GitHub-12 8126358 127.1 ns/op 96 B/op 1 allocs/op
BenchmarkPat/Hello-12 13960442 83.55 ns/op 48 B/op 1 allocs/op
BenchmarkPat/GitHub-12 20936 84570 ns/op 375508 B/op 235 allocs/op
BenchmarkWay/Hello-12 4708562 251.4 ns/op 307 B/op 3 allocs/op
BenchmarkWay/GitHub-12 118218 9903 ns/op 4979 B/op 177 allocs/op
```

21
web/aero_test.go Normal file
View File

@ -0,0 +1,21 @@
package main_test
import (
"testing"
"github.com/aerogo/aero"
)
func BenchmarkAero(b *testing.B) {
bench(
b,
func() *aero.Application {
return aero.New()
},
func(app *aero.Application, method string, path string) {
app.Router().Add(method, path, func(ctx aero.Context) error {
return ctx.Bytes(payload)
})
},
)
}

View File

@ -5,16 +5,28 @@ go 1.22.1
require (
git.akyoto.dev/go/router v0.1.3
git.akyoto.dev/go/server v0.0.0-20240313191801-c13dbc55d263
github.com/aerogo/aero v1.3.59
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/go-zoo/bone v1.3.0
github.com/julienschmidt/httprouter v1.3.0
github.com/labstack/echo/v4 v4.11.4
github.com/matryer/way v0.0.0-20180416093233-9632d0c407b0
)
require (
github.com/aerogo/csp v0.1.10 // indirect
github.com/aerogo/http v1.1.3 // indirect
github.com/aerogo/session v0.1.9 // indirect
github.com/aerogo/session-store-memory v0.1.9 // indirect
github.com/akyoto/color v1.8.12 // indirect
github.com/akyoto/colorable v0.1.7 // indirect
github.com/akyoto/hash v0.5.0 // indirect
github.com/akyoto/stringutils v0.3.1 // indirect
github.com/akyoto/tty v0.1.4 // indirect
github.com/akyoto/uuid v1.1.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
@ -49,6 +61,7 @@ require (
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/zeebo/xxh3 v1.0.1 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect

View File

@ -4,6 +4,33 @@ git.akyoto.dev/go/router v0.1.3 h1:H4wJCYdDD3/i9miYSK/e5sCoGiXe9OX7KmgH4/Toa60=
git.akyoto.dev/go/router v0.1.3/go.mod h1:VfSsK/Z6fUhT3pWaAAnuAcj++bWRZD+bzNaqJoTAunU=
git.akyoto.dev/go/server v0.0.0-20240313191801-c13dbc55d263 h1:t5DctyOnTUPUMQsyHNZefIKYO4TjKq4wXt+2+e37PwY=
git.akyoto.dev/go/server v0.0.0-20240313191801-c13dbc55d263/go.mod h1:VVr9rDl+CPnQyXphXpOcpSovrjzPGsSk00PjUBHkx1c=
github.com/aerogo/aero v1.3.59 h1:5yu+kk/uIXAXADKSLCFKhxAzThCehvpbF6gst+G32Fw=
github.com/aerogo/aero v1.3.59/go.mod h1:ehwj+mb117xQRTvp11jlnrRNPgbcYL6s6aBk9wbIZ0o=
github.com/aerogo/csp v0.1.10 h1:2PJf9gkdRvCFYOA0baTUyp34vwPp5ZJJX8GZRCYc/nM=
github.com/aerogo/csp v0.1.10/go.mod h1:UrxbTXv+X9kJatyuLeu2yGFpOiWVPjbqA/DzqxSVhl8=
github.com/aerogo/http v1.1.3 h1:cvwOYL+zNEfNHvJcX6A6OgUwQ4KROlu8ypuQEQc1HtU=
github.com/aerogo/http v1.1.3/go.mod h1:h+m3WxevpaifyVpRAMV58qt8ScXSZhU1a5DdvBkRwwE=
github.com/aerogo/session v0.1.8/go.mod h1:Q9QqpT8nM6HTaklE14T+bzNSKrwW1M2wZ/NZV1HUTB0=
github.com/aerogo/session v0.1.9 h1:pgsFEtCteOQaZ/103q2/O+qrqZileiCZe+vboWKZMlU=
github.com/aerogo/session v0.1.9/go.mod h1:dgpdXvs9tZXcag5ay6tEoKuySPga226iSh748uIES/E=
github.com/aerogo/session-store-memory v0.1.9 h1:1OswTCtyqzffX5aGr6jI3H8gt/hkU3LKNiKpia7ntcs=
github.com/aerogo/session-store-memory v0.1.9/go.mod h1:z4ZxP+xLVdH69F/Cvgy93v8fWzeDmiJo+Mm+Th3un4c=
github.com/akyoto/assert v0.2.3/go.mod h1:g5e6ag+ksCEQENq/LnmU9z04wCAIFDr8KacBusVL0H8=
github.com/akyoto/assert v0.2.4 h1:n0FwcNH5dMYq3I8Iu7MOR1WWGkkGH8ao84nvCRJmsbs=
github.com/akyoto/assert v0.2.4/go.mod h1:SoqVayyOmM/YSBnwOxJHCt4BCocoIrgeceWtJV701C0=
github.com/akyoto/color v1.8.12 h1:7F/iF/POG6z+oppoGYWO6UOx8E2ZAypANO9rsfsBuHI=
github.com/akyoto/color v1.8.12/go.mod h1:rG1eiYoSE+arV6oLuGuuekPtgujUlIErWeqqM13pVoA=
github.com/akyoto/colorable v0.1.7 h1:ge91E25hiOiT/Zu47ij/rTO3cks7wMlTrcQspua1hFM=
github.com/akyoto/colorable v0.1.7/go.mod h1:zlc1+Es4DyoXzDdbKiSfvdM6R/DsWS8bFi4RHigkuu4=
github.com/akyoto/hash v0.5.0 h1:NAOZ8EySEOzlLpiURs4PLx26Hxsv8vkxpySElJ5U9FY=
github.com/akyoto/hash v0.5.0/go.mod h1:/ftTams8jMXYuc4NWDzdA6sEztxFslBS+VdqYZQZCNI=
github.com/akyoto/stringutils v0.3.1 h1:C+VGuXfud9SSo54QRfdQO+rgQiHmLS5f4nJ4yUOM+8I=
github.com/akyoto/stringutils v0.3.1/go.mod h1:I1F9f8FF7gnAQyYp4PVAl+GJ2WBnaN6kNoYjidCV5Qk=
github.com/akyoto/tty v0.1.3/go.mod h1:+VlbvviCaiwhS4oGpO+iBtC0lYG1ilIs3ZhUnT1Ppgo=
github.com/akyoto/tty v0.1.4 h1:TELbnAmrPTIrUJyuBLhrOSCcBnklC2fh0YeCTjksiDE=
github.com/akyoto/tty v0.1.4/go.mod h1:fkWwtA4F5Cq9kiQSlWdkPy5kAyySGYqalWyaRKn3zHo=
github.com/akyoto/uuid v1.1.3 h1:FEz14tNTfaUeY0Jrkz2F17rjKiks6hOALGcPmAmtn1s=
github.com/akyoto/uuid v1.1.3/go.mod h1:8dgzDQyrpuApBGIQHOX7JkvCZHusXZ0tGlQcxxv4bYg=
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=
@ -57,6 +84,8 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
@ -122,6 +151,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/zeebo/xxh3 v1.0.1 h1:FMSRIbkrLikb/0hZxmltpg84VkqDAT5M8ufXynuhXsI=
github.com/zeebo/xxh3 v1.0.1/go.mod h1:8VHV24/3AZLn3b6Mlp/KuC33LWH687Wq6EnziEB+rsA=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
@ -130,6 +161,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20191025090151-53bf42e6b339/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

22
web/httprouter_test.go Normal file
View File

@ -0,0 +1,22 @@
package main_test
import (
"net/http"
"testing"
"github.com/julienschmidt/httprouter"
)
func BenchmarkJSHR(b *testing.B) {
bench(
b,
func() *httprouter.Router {
return httprouter.New()
},
func(r *httprouter.Router, method string, path string) {
r.Handle(method, path, func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
w.Write(payload)
})
},
)
}