Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wklken/12ad5a3137dd0962902dce415c8f5e9d to your computer and use it in GitHub Desktop.
Save wklken/12ad5a3137dd0962902dce415c8f5e9d to your computer and use it in GitHub Desktop.
##
## HTTP Router benchmarks -- Jan 9, 2019 with Go 1.11.4 on Linux X1 Carbon laptop
##
## This benchmark suite is based on https://github.com/julienschmidt/go-http-routing-benchmark
## using the most up-to-date version of each pkg as of today. Each router has their own
## pros and cons, so consider the designs of each router to suit your application.
##
## We use the most up-to-date version of each router available in the tests below.
##
[peter@pak ~/Dev/go/src/github.com/pkieltyka/go-http-routing-benchmark]$ go test -v -bench="Chi" .
#GithubAPI Routes: 203
Chi: 95112 Bytes
#GPlusAPI Routes: 13
Chi: 8008 Bytes
#ParseAPI Routes: 26
Chi: 9728 Bytes
#Static Routes: 157
Chi: 82416 Bytes
=== RUN TestRouters
--- PASS: TestRouters (0.06s)
goos: linux
goarch: amd64
pkg: github.com/pkieltyka/go-http-routing-benchmark
BenchmarkChi_Param 3000000 468 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Param5 2000000 680 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Param20 1000000 1301 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParamWrite 3000000 505 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubStatic 3000000 447 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubParam 2000000 664 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubAll 10000 137857 ns/op 87699 B/op 609 allocs/op
BenchmarkChi_GPlusStatic 3000000 410 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlusParam 3000000 509 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlus2Params 3000000 592 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlusAll 200000 7341 ns/op 5616 B/op 39 allocs/op
BenchmarkChi_ParseStatic 3000000 418 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParseParam 3000000 497 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Parse2Params 3000000 560 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParseAll 100000 13836 ns/op 11232 B/op 78 allocs/op
BenchmarkChi_StaticAll 20000 82180 ns/op 67826 B/op 471 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 30.169s
[peter@pak ~/Dev/go/src/github.com/pkieltyka/go-http-routing-benchmark]$ go test -v -bench="Chi|HttpRouter|Goji|Martini|Gorilla|Gocraft|Beego|Gin" .
#GithubAPI Routes: 203
Beego: 151160 Bytes
Chi: 95112 Bytes
Gin: 51984 Bytes
GocraftWeb: 95640 Bytes
Goji: 84040 Bytes
GorillaMux: 1322784 Bytes
HttpRouter: 37016 Bytes
Martini: 560240 Bytes
#GPlusAPI Routes: 13
Beego: 10256 Bytes
Chi: 8008 Bytes
Gin: 3936 Bytes
GocraftWeb: 7496 Bytes
Goji: 2912 Bytes
GorillaMux: 66208 Bytes
HttpRouter: 2712 Bytes
Martini: 23936 Bytes
#ParseAPI Routes: 26
Beego: 19360 Bytes
Chi: 9728 Bytes
Gin: 6912 Bytes
GocraftWeb: 12800 Bytes
Goji: 5232 Bytes
GorillaMux: 105880 Bytes
HttpRouter: 4960 Bytes
Martini: 45904 Bytes
#Static Routes: 157
Beego: 98920 Bytes
Chi: 82416 Bytes
Gin: 30480 Bytes
GocraftWeb: 55096 Bytes
Goji: 27200 Bytes
GorillaMux: 586192 Bytes
HttpRouter: 21016 Bytes
Martini: 310880 Bytes
=== RUN TestRouters
--- PASS: TestRouters (0.09s)
goos: linux
goarch: amd64
pkg: github.com/pkieltyka/go-http-routing-benchmark
BenchmarkBeego_Param 1000000 1098 ns/op 352 B/op 3 allocs/op
BenchmarkChi_Param 2000000 866 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param 30000000 53.2 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param 1000000 1122 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_Param 3000000 501 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param 500000 2159 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_Param 20000000 87.2 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_Param 300000 3924 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Param5 1000000 1243 ns/op 352 B/op 3 allocs/op
BenchmarkChi_Param5 1000000 1135 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param5 20000000 88.3 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param5 1000000 1789 ns/op 920 B/op 11 allocs/op
BenchmarkGoji_Param5 2000000 694 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param5 500000 3149 ns/op 1344 B/op 10 allocs/op
BenchmarkHttpRouter_Param5 5000000 252 ns/op 160 B/op 1 allocs/op
BenchmarkMartini_Param5 300000 4645 ns/op 1232 B/op 11 allocs/op
BenchmarkBeego_Param20 500000 2543 ns/op 352 B/op 3 allocs/op
BenchmarkChi_Param20 1000000 1677 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param20 10000000 231 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param20 200000 6853 ns/op 3795 B/op 15 allocs/op
BenchmarkGoji_Param20 1000000 2133 ns/op 1246 B/op 2 allocs/op
BenchmarkGorillaMux_Param20 200000 7225 ns/op 3451 B/op 12 allocs/op
BenchmarkHttpRouter_Param20 2000000 858 ns/op 640 B/op 1 allocs/op
BenchmarkMartini_Param20 200000 9188 ns/op 3596 B/op 13 allocs/op
BenchmarkBeego_ParamWrite 1000000 1151 ns/op 360 B/op 4 allocs/op
BenchmarkChi_ParamWrite 2000000 923 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParamWrite 20000000 112 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParamWrite 1000000 1242 ns/op 656 B/op 9 allocs/op
BenchmarkGoji_ParamWrite 3000000 550 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParamWrite 500000 2293 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_ParamWrite 10000000 116 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_ParamWrite 300000 4523 ns/op 1176 B/op 14 allocs/op
BenchmarkBeego_GithubStatic 1000000 1109 ns/op 352 B/op 3 allocs/op
BenchmarkChi_GithubStatic 2000000 824 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GithubStatic 20000000 71.9 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubStatic 2000000 770 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_GithubStatic 10000000 173 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GithubStatic 100000 12037 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_GithubStatic 30000000 39.0 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GithubStatic 200000 11703 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GithubParam 1000000 1058 ns/op 352 B/op 3 allocs/op
BenchmarkChi_GithubParam 2000000 939 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GithubParam 20000000 114 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubParam 1000000 1274 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GithubParam 2000000 754 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GithubParam 200000 7477 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_GithubParam 10000000 203 ns/op 96 B/op 1 allocs/op
BenchmarkMartini_GithubParam 200000 8770 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_GithubAll 10000 224747 ns/op 71457 B/op 609 allocs/op
BenchmarkChi_GithubAll 10000 194381 ns/op 87697 B/op 609 allocs/op
BenchmarkGin_GithubAll 50000 24026 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubAll 5000 261300 ns/op 131656 B/op 1686 allocs/op
BenchmarkGoji_GithubAll 5000 347009 ns/op 56112 B/op 334 allocs/op
BenchmarkGorillaMux_GithubAll 300 4326924 ns/op 251648 B/op 1994 allocs/op
BenchmarkHttpRouter_GithubAll 50000 35140 ns/op 13792 B/op 167 allocs/op
BenchmarkMartini_GithubAll 500 3449257 ns/op 226550 B/op 2325 allocs/op
BenchmarkBeego_GPlusStatic 2000000 812 ns/op 352 B/op 3 allocs/op
BenchmarkChi_GPlusStatic 3000000 523 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlusStatic 30000000 55.6 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusStatic 3000000 464 ns/op 280 B/op 5 allocs/op
BenchmarkGoji_GPlusStatic 10000000 131 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GPlusStatic 1000000 1234 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_GPlusStatic 50000000 23.7 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GPlusStatic 500000 3375 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GPlusParam 2000000 893 ns/op 352 B/op 3 allocs/op
BenchmarkChi_GPlusParam 3000000 606 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlusParam 20000000 74.2 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusParam 2000000 862 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_GPlusParam 3000000 469 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlusParam 500000 2513 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_GPlusParam 10000000 119 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlusParam 300000 3964 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_GPlus2Params 2000000 993 ns/op 352 B/op 3 allocs/op
BenchmarkChi_GPlus2Params 2000000 694 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlus2Params 20000000 94.0 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlus2Params 1000000 1080 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GPlus2Params 2000000 666 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlus2Params 300000 5580 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_GPlus2Params 10000000 146 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlus2Params 200000 8093 ns/op 1200 B/op 13 allocs/op
BenchmarkBeego_GPlusAll 200000 12075 ns/op 4576 B/op 39 allocs/op
BenchmarkChi_GPlusAll 200000 8706 ns/op 5616 B/op 39 allocs/op
BenchmarkGin_GPlusAll 1000000 1001 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusAll 200000 12340 ns/op 8040 B/op 103 allocs/op
BenchmarkGoji_GPlusAll 200000 6591 ns/op 3696 B/op 22 allocs/op
BenchmarkGorillaMux_GPlusAll 50000 39946 ns/op 16112 B/op 128 allocs/op
BenchmarkHttpRouter_GPlusAll 1000000 1501 ns/op 640 B/op 11 allocs/op
BenchmarkMartini_GPlusAll 20000 65388 ns/op 14016 B/op 145 allocs/op
BenchmarkChi_ParseStatic 3000000 522 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParseStatic 30000000 58.4 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseStatic 3000000 536 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_ParseStatic 10000000 165 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_ParseStatic 1000000 1884 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_ParseStatic 50000000 25.3 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_ParseStatic 500000 3692 ns/op 768 B/op 9 allocs/op
BenchmarkChi_ParseParam 3000000 592 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParseParam 20000000 61.2 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseParam 2000000 931 ns/op 664 B/op 8 allocs/op
BenchmarkGoji_ParseParam 3000000 523 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParseParam 1000000 1994 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_ParseParam 20000000 108 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_ParseParam 300000 4060 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Parse2Params 2000000 922 ns/op 352 B/op 3 allocs/op
BenchmarkChi_Parse2Params 2000000 657 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Parse2Params 20000000 73.3 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Parse2Params 1000000 1054 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_Parse2Params 3000000 519 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Parse2Params 500000 2269 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_Parse2Params 10000000 124 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_Parse2Params 300000 4015 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_ParseAll 100000 22524 ns/op 9152 B/op 78 allocs/op
BenchmarkChi_ParseAll 100000 16790 ns/op 11232 B/op 78 allocs/op
BenchmarkGin_ParseAll 1000000 1886 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseAll 100000 21159 ns/op 13728 B/op 181 allocs/op
BenchmarkGoji_ParseAll 200000 11063 ns/op 5376 B/op 32 allocs/op
BenchmarkGorillaMux_ParseAll 20000 79417 ns/op 30288 B/op 250 allocs/op
BenchmarkHttpRouter_ParseAll 1000000 1941 ns/op 640 B/op 16 allocs/op
BenchmarkMartini_ParseAll 10000 110574 ns/op 25072 B/op 253 allocs/op
BenchmarkBeego_StaticAll 10000 150950 ns/op 55264 B/op 471 allocs/op
BenchmarkChi_StaticAll 10000 100046 ns/op 67824 B/op 471 allocs/op
BenchmarkGin_StaticAll 100000 16630 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_StaticAll 20000 91289 ns/op 46440 B/op 785 allocs/op
BenchmarkGoji_StaticAll 50000 38554 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_StaticAll 1000 1172397 ns/op 153328 B/op 1421 allocs/op
BenchmarkHttpRouter_StaticAll 200000 9220 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 229.502s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment