Skip to content

Commit

Permalink
add tinyrouter
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Jul 16, 2018
1 parent 9076dd8 commit 79d8b02
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -56,6 +56,7 @@ This benchmark suite aims to compare the performance of Go web frameworks. It is
* [siris](https://github.com/go-siris/siris)
* [FastRouter](https://github.com/razonyang/fastrouter)
* [negroni](https://github.com/urfave/negroni)
* [tinyrouter](https://github.com/go101/tinyrouter)

The below web frameworks will be removed from this test because of their poor performance:
* [possum](https://github.com/mikespook/possum)
Expand Down
2 changes: 1 addition & 1 deletion libs.sh
Expand Up @@ -2,4 +2,4 @@

web_frameworks=( "default" "ace" "beego" "bone" "chi" "denco" "echov3" "fasthttp-raw" \
"fasthttprouter" "fasthttp-routing" "fastrouter" "fresh" "gear" "gin" "goji" "gojsonrest" "gongular" "gorestful" "gorilla" "go-ozzo" "gowww" "gramework" "httprouter" \
"httptreemux" "lars" "lion" "martini" "negroni" "neo" "pat" "pure" "r2router" "siris" "tango" "tiger" "traffic" "violetear" "vulcan")
"httptreemux" "lars" "lion" "martini" "negroni" "neo" "pat" "pure" "r2router" "siris" "tango" "tiger" "tinyrouter" "traffic" "violetear" "vulcan")
Binary file removed server
Binary file not shown.
15 changes: 15 additions & 0 deletions server.go
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/go-playground/lars"
"github.com/go-playground/pure"
"github.com/go-zoo/bone"
tiny "github.com/go101/tinyrouter"
"github.com/gocraft/web"
"github.com/gorilla/mux"
gowwwrouter "github.com/gowww/router"
Expand Down Expand Up @@ -183,6 +184,8 @@ func main() {
startTango()
case "tiger":
startTigerTonic()
case "tinyrouter":
startTinyRouter()
case "traffic":
startTraffic()
case "violetear":
Expand Down Expand Up @@ -798,6 +801,18 @@ func startTigerTonic() {
http.ListenAndServe(":"+strconv.Itoa(port), mux)
}

// TinyRouter
func startTinyRouter() {
routes := []tiny.Route{
{
Method: "GET",
Pattern: "/hello",
HandleFunc: helloHandler,
}}
router := tiny.New(tiny.Config{Routes: routes})
http.ListenAndServe(":"+strconv.Itoa(port), router)
}

// traffic
func trafficHandler(w traffic.ResponseWriter, r *traffic.Request) {
if sleepTime > 0 {
Expand Down

0 comments on commit 79d8b02

Please sign in to comment.