Skip to content

Commit

Permalink
Merge pull request #14 from lkeix/main
Browse files Browse the repository at this point in the history
Add N9tE9 Router
  • Loading branch information
bmf-san authored Dec 18, 2022
2 parents de8b80b + 699280c commit 5c5f75a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
37 changes: 37 additions & 0 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,40 @@ func BenchmarkPathParamInequalitySignRoutes10OzzoRouting(b *testing.B) {
router := loadOzzoRouting(pathParamInequalitySignRoutes10)
benchmark(b, pathParamInequalitySignRoutes10, router)
}

// n9te9 router
// https://github.com/lkeix/techbook13-sample
func BenchmarkStaticRoutesRootN9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(staticRoutesRoot)
benchmark(b, staticRoutesRoot, router)
}

func BenchmarkStaticRoutes1ON9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(staticRoutes1)
benchmark(b, staticRoutes1, router)
}

func BenchmarkStaticRoutes5ON9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(staticRoutes5)
benchmark(b, staticRoutes5, router)
}

func BenchmarkStaticRoutes10N9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(staticRoutes10)
benchmark(b, staticRoutes10, router)
}

func BenchmarkPathParamColonRoutes1N9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(pathParamColonRoutes1)
benchmark(b, pathParamColonRoutes1, router)
}

func BenchmarkPathParamColonRoutes5N9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(pathParamColonRoutes5)
benchmark(b, pathParamColonRoutes5, router)
}

func BenchmarkPathParamColonRoutes10N9tE9Routing(b *testing.B) {
router := loadN9tE9Routing(pathParamColonRoutes10)
benchmark(b, pathParamColonRoutes10, router)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/julienschmidt/httprouter v1.3.0
github.com/labstack/echo v3.3.10+incompatible
github.com/lkeix/techbook13-sample v0.0.0-20221218104044-fc1348dfcf99
github.com/naoina/denco v0.0.0-20180930074809-8475105a6b4c
github.com/nissy/bon v1.3.0
github.com/uptrace/bunrouter v1.0.19
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lkeix/techbook13-sample v0.0.0-20221218092033-e931bc058308 h1:yAm/CP6/sf7qXsF9QbjYZJZnuRWzB9idliUqpmdq3lM=
github.com/lkeix/techbook13-sample v0.0.0-20221218092033-e931bc058308/go.mod h1:zxho/HpBxK5SXApnM9A0dNegTEWHAXxVi7B0AAKNsZk=
github.com/lkeix/techbook13-sample v0.0.0-20221218104044-fc1348dfcf99 h1:Pt0zPDvQoGb0aeo5OhWPUg7AyucLrhMXHbKHu6ovdSE=
github.com/lkeix/techbook13-sample v0.0.0-20221218104044-fc1348dfcf99/go.mod h1:zxho/HpBxK5SXApnM9A0dNegTEWHAXxVi7B0AAKNsZk=
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
Expand Down
8 changes: 8 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
gorillamux "github.com/gorilla/mux"
"github.com/julienschmidt/httprouter"
"github.com/labstack/echo"
"github.com/lkeix/techbook13-sample/router"
"github.com/naoina/denco"
"github.com/nissy/bon"
"github.com/uptrace/bunrouter"
Expand Down Expand Up @@ -140,3 +141,10 @@ func loadOzzoRouting(r route) http.Handler {
router.Get(r.path, handler)
return router
}

func loadN9tE9Routing(r route) http.Handler {
router := router.NewRouter()
handler := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})
router.Insert(r.path, handler)
return router
}

0 comments on commit 5c5f75a

Please sign in to comment.