Skip to content

Commit 9aaad63

Browse files
Merge branch 'master' into master
2 parents 94e0eae + b81acfd commit 9aaad63

File tree

11 files changed

+527
-195
lines changed

11 files changed

+527
-195
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
sudo: false
22
language: go
33
go:
4-
- 1.8
5-
- tip
4+
- 1.13.x

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ go test -bench=.
388388

389389
> **Note:** If you run the tests and it SIGQUIT's make the go test timeout longer (#44)
390390
>
391-
>```
391+
```
392392
go test -timeout=2h -bench=.
393393
```
394394

bench_test.go

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func calcMem(name string, load func()) {
4545
m := new(runtime.MemStats)
4646

4747
// before
48+
// force GC multiple times, since Go is using a generational GC
49+
// TODO: find a better approach
50+
runtime.GC()
51+
runtime.GC()
52+
runtime.GC()
4853
runtime.GC()
4954
runtime.ReadMemStats(m)
5055
before := m.HeapAlloc
@@ -53,6 +58,9 @@ func calcMem(name string, load func()) {
5358

5459
// after
5560
runtime.GC()
61+
runtime.GC()
62+
runtime.GC()
63+
runtime.GC()
5664
runtime.ReadMemStats(m)
5765
after := m.HeapAlloc
5866
println(" "+name+":", after-before, "Bytes")
@@ -232,7 +240,6 @@ func BenchmarkPat_Param(b *testing.B) {
232240
r, _ := http.NewRequest("GET", "/user/gordon", nil)
233241
benchRequest(b, router, r)
234242
}
235-
236243
func BenchmarkPossum_Param(b *testing.B) {
237244
router := loadPossumSingle("GET", "/user/:name", possumHandler)
238245

@@ -246,12 +253,12 @@ func BenchmarkR2router_Param(b *testing.B) {
246253
benchRequest(b, router, r)
247254
}
248255

249-
func BenchmarkRevel_Param(b *testing.B) {
250-
router := loadRevelSingle("GET", "/user/:name", "RevelController.Handle")
256+
// func BenchmarkRevel_Param(b *testing.B) {
257+
// router := loadRevelSingle("GET", "/user/:name", "RevelController.Handle")
251258

252-
r, _ := http.NewRequest("GET", "/user/gordon", nil)
253-
benchRequest(b, router, r)
254-
}
259+
// r, _ := http.NewRequest("GET", "/user/gordon", nil)
260+
// benchRequest(b, router, r)
261+
// }
255262
func BenchmarkRivet_Param(b *testing.B) {
256263
router := loadRivetSingle("GET", "/user/:name", rivetHandler)
257264

@@ -444,12 +451,12 @@ func BenchmarkR2router_Param5(b *testing.B) {
444451
benchRequest(b, router, r)
445452
}
446453

447-
func BenchmarkRevel_Param5(b *testing.B) {
448-
router := loadRevelSingle("GET", fiveColon, "RevelController.Handle")
454+
// func BenchmarkRevel_Param5(b *testing.B) {
455+
// router := loadRevelSingle("GET", fiveColon, "RevelController.Handle")
449456

450-
r, _ := http.NewRequest("GET", fiveRoute, nil)
451-
benchRequest(b, router, r)
452-
}
457+
// r, _ := http.NewRequest("GET", fiveRoute, nil)
458+
// benchRequest(b, router, r)
459+
// }
453460
func BenchmarkRivet_Param5(b *testing.B) {
454461
router := loadRivetSingle("GET", fiveColon, rivetHandler)
455462

@@ -642,12 +649,12 @@ func BenchmarkR2router_Param20(b *testing.B) {
642649
benchRequest(b, router, r)
643650
}
644651

645-
func BenchmarkRevel_Param20(b *testing.B) {
646-
router := loadRevelSingle("GET", twentyColon, "RevelController.Handle")
652+
// func BenchmarkRevel_Param20(b *testing.B) {
653+
// router := loadRevelSingle("GET", twentyColon, "RevelController.Handle")
647654

648-
r, _ := http.NewRequest("GET", twentyRoute, nil)
649-
benchRequest(b, router, r)
650-
}
655+
// r, _ := http.NewRequest("GET", twentyRoute, nil)
656+
// benchRequest(b, router, r)
657+
// }
651658
func BenchmarkRivet_Param20(b *testing.B) {
652659
router := loadRivetSingle("GET", twentyColon, rivetHandler)
653660

@@ -836,12 +843,12 @@ func BenchmarkR2router_ParamWrite(b *testing.B) {
836843
benchRequest(b, router, r)
837844
}
838845

839-
func BenchmarkRevel_ParamWrite(b *testing.B) {
840-
router := loadRevelSingle("GET", "/user/:name", "RevelController.HandleWrite")
846+
// func BenchmarkRevel_ParamWrite(b *testing.B) {
847+
// router := loadRevelSingle("GET", "/user/:name", "RevelController.HandleWrite")
841848

842-
r, _ := http.NewRequest("GET", "/user/gordon", nil)
843-
benchRequest(b, router, r)
844-
}
849+
// r, _ := http.NewRequest("GET", "/user/gordon", nil)
850+
// benchRequest(b, router, r)
851+
// }
845852
func BenchmarkRivet_ParamWrite(b *testing.B) {
846853
router := loadRivetSingle("GET", "/user/:name", rivetHandlerWrite)
847854

github_test.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ func init() {
382382
calcMem("R2router", func() {
383383
githubR2router = loadR2router(githubAPI)
384384
})
385-
calcMem("Revel", func() {
386-
githubRevel = loadRevel(githubAPI)
387-
})
385+
// calcMem("Revel", func() {
386+
// githubRevel = loadRevel(githubAPI)
387+
// })
388388
calcMem("Rivet", func() {
389389
githubRivet = loadRivet(githubAPI)
390390
})
@@ -504,10 +504,11 @@ func BenchmarkR2router_GithubStatic(b *testing.B) {
504504
req, _ := http.NewRequest("GET", "/user/repos", nil)
505505
benchRequest(b, githubR2router, req)
506506
}
507-
func BenchmarkRevel_GithubStatic(b *testing.B) {
508-
req, _ := http.NewRequest("GET", "/user/repos", nil)
509-
benchRequest(b, githubRevel, req)
510-
}
507+
508+
// func BenchmarkRevel_GithubStatic(b *testing.B) {
509+
// req, _ := http.NewRequest("GET", "/user/repos", nil)
510+
// benchRequest(b, githubRevel, req)
511+
// }
511512
func BenchmarkRivet_GithubStatic(b *testing.B) {
512513
req, _ := http.NewRequest("GET", "/user/repos", nil)
513514
benchRequest(b, githubRivet, req)
@@ -631,10 +632,11 @@ func BenchmarkR2router_GithubParam(b *testing.B) {
631632
req, _ := http.NewRequest("GET", "/repos/julienschmidt/httprouter/stargazers", nil)
632633
benchRequest(b, githubR2router, req)
633634
}
634-
func BenchmarkRevel_GithubParam(b *testing.B) {
635-
req, _ := http.NewRequest("GET", "/repos/julienschmidt/httprouter/stargazers", nil)
636-
benchRequest(b, githubRevel, req)
637-
}
635+
636+
// func BenchmarkRevel_GithubParam(b *testing.B) {
637+
// req, _ := http.NewRequest("GET", "/repos/julienschmidt/httprouter/stargazers", nil)
638+
// benchRequest(b, githubRevel, req)
639+
// }
638640
func BenchmarkRivet_GithubParam(b *testing.B) {
639641
req, _ := http.NewRequest("GET", "/repos/julienschmidt/httprouter/stargazers", nil)
640642
benchRequest(b, githubRivet, req)
@@ -734,9 +736,10 @@ func BenchmarkPossum_GithubAll(b *testing.B) {
734736
func BenchmarkR2router_GithubAll(b *testing.B) {
735737
benchRoutes(b, githubR2router, githubAPI)
736738
}
737-
func BenchmarkRevel_GithubAll(b *testing.B) {
738-
benchRoutes(b, githubRevel, githubAPI)
739-
}
739+
740+
// func BenchmarkRevel_GithubAll(b *testing.B) {
741+
// benchRoutes(b, githubRevel, githubAPI)
742+
// }
740743
func BenchmarkRivet_GithubAll(b *testing.B) {
741744
benchRoutes(b, githubRivet, githubAPI)
742745
}

go.mod

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module github.com/julienschmidt/go-http-routing-benchmark
2+
3+
go 1.13
4+
5+
require (
6+
github.com/ant0ine/go-json-rest v3.3.2+incompatible
7+
github.com/astaxie/beego v1.12.0
8+
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40
9+
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
10+
github.com/dimfeld/httptreemux v5.0.1+incompatible
11+
github.com/emicklei/go-restful v2.10.0+incompatible
12+
github.com/fsnotify/fsnotify v1.4.7 // indirect
13+
github.com/gin-gonic/gin v1.4.0
14+
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab
15+
github.com/go-playground/form v3.1.4+incompatible // indirect
16+
github.com/go-playground/lars v4.0.1+incompatible
17+
github.com/go-zoo/bone v1.3.0
18+
github.com/gocraft/web v0.0.0-20190207150652-9707327fb69b
19+
github.com/gorilla/mux v1.7.3
20+
github.com/gorilla/sessions v1.2.0 // indirect
21+
github.com/gorilla/websocket v1.4.1 // indirect
22+
github.com/gravitational/trace v0.0.0-20190726142706-a535a178675f // indirect
23+
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec // indirect
24+
github.com/jonboulle/clockwork v0.1.0 // indirect
25+
github.com/julienschmidt/httprouter v1.2.0
26+
github.com/labstack/echo v3.3.10+incompatible
27+
github.com/labstack/gommon v0.3.0 // indirect
28+
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de
29+
github.com/lunny/tango v0.5.6
30+
github.com/mailgun/route v0.0.0-20181101151700-58b44163b968
31+
github.com/mikespook/possum v0.0.0-20170224044927-56d7ebb6470b
32+
github.com/naoina/denco v0.0.0-20180930074809-8475105a6b4c
33+
github.com/naoina/kocha-urlrouter v0.0.0-20140609163054-ad3a6f079210
34+
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
35+
github.com/philhofer/fwd v1.0.0 // indirect
36+
github.com/pilu/config v0.0.0-20131214182432-3eb99e6c0b9a // indirect
37+
github.com/pilu/miniassert v0.0.0-20140522125902-bee63581261a // indirect
38+
github.com/pilu/traffic v0.5.3
39+
github.com/plimble/ace v0.0.0-20180623113504-ba79f505f416
40+
github.com/plimble/sessions v0.0.0-20180326075456-7047d39da9ad // indirect
41+
github.com/plimble/utils v0.0.0-20150615054616-fe08d46675cd // indirect
42+
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 // indirect
43+
github.com/rcrowley/go-tigertonic v0.0.0-20170420123839-fe6b9f080eb7
44+
github.com/revel/config v0.21.0 // indirect
45+
github.com/revel/log15 v2.11.20+incompatible // indirect
46+
github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9
47+
github.com/revel/revel v0.21.0
48+
github.com/robfig/pathtree v0.0.0-20140121041023-41257a1839e9
49+
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
50+
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
51+
github.com/sirupsen/logrus v1.4.2 // indirect
52+
github.com/tinylib/msgp v1.1.0 // indirect
53+
github.com/twinj/uuid v1.0.0 // indirect
54+
github.com/typepress/rivet v1.1.1-0.20151208095308-d62b4fcaf6b9
55+
github.com/ursiform/bear v1.0.1
56+
github.com/vanng822/r2router v0.0.0-20150523112421-1023140a4f30
57+
github.com/vulcand/predicate v1.1.0 // indirect
58+
github.com/xeonx/timeago v1.0.0-rc4 // indirect
59+
github.com/zenazn/goji v0.9.0
60+
goji.io v2.0.2+incompatible
61+
gopkg.in/fsnotify.v1 v1.4.7 // indirect
62+
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
63+
gopkg.in/macaron.v1 v1.3.4
64+
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
65+
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 // indirect
66+
)

0 commit comments

Comments
 (0)