Skip to content

Commit

Permalink
benchmarks: add two more routers
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Oct 16, 2018
1 parent f9628a3 commit 1fc2d0e
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<a href="https://twitter.com/MakisMaropoulos">Gerasimos Maropoulos</a>
</div>

[![Benchmark chart between muxie, httprouter, gin and gorilla mux](_benchmarks/chart-15-oct-2018.png)](_benchmarks)
[![Benchmark chart between muxie, httprouter, gin, gorilla mux, echo and vestigo](_benchmarks/chart-16-oct-2018.png)](_benchmarks)

_Last updated on October 15, 2018._ Click [here](_benchmarks/README.md) to read more details.
_Last updated on October 16, 2018._ Click [here](_benchmarks/README.md) to read more details.

## Features

Expand Down
32 changes: 30 additions & 2 deletions _benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Benchmarks

Last updated on October 15, 2018.
Last updated on October 16, 2018.

> October 16: add echo and vestigo benchmarks against the same environments
> October 15: benchmark between muxie, httprouter, gin and gorilla mux
## Hardware

Expand All @@ -20,9 +24,17 @@ Last updated on October 15, 2018.
* Bench code: [gin/main.go](gin/main.go)
* **gorilla mux**: https://github.com/gorilla/mux, latest version **1.6.2**
* Bench code: [gorilla-mux/main.go](gorilla-mux/main.go)
* **echo**: https://github.com/labstack/echo, latest version **3.3.6**
* Bench code: [echo/main.go](echo/main.go)
* **vestigo**: https://github.com/husobee/vestigo, latest version **1.1.0**
* Bench code: [vestigo/main.go](vestigo/main.go)

## Results

![Benchmark chart between muxie, httprouter, gin, gorilla mux, echo and vestigo](chart-16-oct-2018.png)

> Higher is better
### Static Path

```sh
Expand All @@ -45,6 +57,14 @@ bombardier -c 125 -n 1000000 http://localhost:3000

![](static_path_gorilla-mux.png)

#### Echo

![](static_path_echo.png)

#### Vestigo

![](static_path_vestigo.png)

### Parameterized (dynamic) Path

```sh
Expand All @@ -65,4 +85,12 @@ bombardier -c 125 -n 1000000 http://localhost:3000/user/42

#### Gorilla Mux

![](parameterized_path_gorilla-mux.png)
![](parameterized_path_gorilla-mux.png)

#### Echo

![](parameterized_path_echo.png)

#### Vestigo

![](parameterized_path_vestigo.png)
Binary file removed _benchmarks/chart-15-oct-2018.png
Binary file not shown.
Binary file added _benchmarks/chart-16-oct-2018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions _benchmarks/echo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"net/http"

"github.com/labstack/echo"
)

func main() {
r := echo.New()

r.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Welcome!\n")
})

r.GET("/user/:id", func(c echo.Context) error {
return c.String(http.StatusOK, c.Param("id"))
})

r.Start(":3000")
}
Binary file added _benchmarks/parameterized_path_echo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _benchmarks/parameterized_path_vestigo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _benchmarks/static_path_echo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _benchmarks/static_path_vestigo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions _benchmarks/vestigo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"net/http"

"github.com/husobee/vestigo"
)

func main() {
r := vestigo.NewRouter()

r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Welcome!\n"))
})

r.Get("/user/:id", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(vestigo.Param(r, "id")))
})

fmt.Println("Server started at localhost:3000")
http.ListenAndServe(":3000", r)
}

0 comments on commit 1fc2d0e

Please sign in to comment.