Skip to content

Instantly share code, notes, and snippets.

@pkieltyka
Last active June 24, 2019 09:03
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkieltyka/c089f309abeb179cfc4deaa519956d8c to your computer and use it in GitHub Desktop.
Save pkieltyka/c089f309abeb179cfc4deaa519956d8c to your computer and use it in GitHub Desktop.
##
## HTTP Router benchmarks -- August 31st, 2017 running Go 1.9.0
##
## 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.
##
[peter@pak ~/Dev/go/src/github.com/pkieltyka/go-http-routing-benchmark]$ go test -v -bench="Chi" .
#GithubAPI Routes: 203
Chi: 95096 Bytes
#GPlusAPI Routes: 13
Chi: 7992 Bytes
#ParseAPI Routes: 26
Chi: 9712 Bytes
#Static Routes: 157
Chi: 82432 Bytes
=== RUN TestRouters
--- PASS: TestRouters (0.89s)
goos: darwin
goarch: amd64
pkg: github.com/pkieltyka/go-http-routing-benchmark
BenchmarkChi_Param 3000000 607 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Param5 2000000 935 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Param20 1000000 1944 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParamWrite 2000000 664 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubStatic 2000000 627 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubParam 2000000 847 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GithubAll 10000 175556 ns/op 87700 B/op 609 allocs/op
BenchmarkChi_GPlusStatic 3000000 566 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlusParam 2000000 652 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlus2Params 2000000 767 ns/op 432 B/op 3 allocs/op
BenchmarkChi_GPlusAll 200000 9794 ns/op 5616 B/op 39 allocs/op
BenchmarkChi_ParseStatic 3000000 590 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParseParam 2000000 656 ns/op 432 B/op 3 allocs/op
BenchmarkChi_Parse2Params 2000000 715 ns/op 432 B/op 3 allocs/op
BenchmarkChi_ParseAll 100000 18045 ns/op 11232 B/op 78 allocs/op
BenchmarkChi_StaticAll 10000 108871 ns/op 67827 B/op 471 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 34.546s
[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: 148216 Bytes
Chi: 95096 Bytes
Gin: 52592 Bytes
GocraftWeb: 95432 Bytes
Goji: 86088 Bytes
GorillaMux: 1325984 Bytes
HttpRouter: 37464 Bytes
Martini: 564368 Bytes
#GPlusAPI Routes: 13
Beego: 10080 Bytes
Chi: 7992 Bytes
Gin: 3968 Bytes
GocraftWeb: 7496 Bytes
Goji: 2912 Bytes
GorillaMux: 66320 Bytes
HttpRouter: 2712 Bytes
Martini: 23936 Bytes
#ParseAPI Routes: 26
Beego: 18960 Bytes
Chi: 9712 Bytes
Gin: 6912 Bytes
GocraftWeb: 12800 Bytes
Goji: 5232 Bytes
GorillaMux: 106200 Bytes
HttpRouter: 4976 Bytes
Martini: 45952 Bytes
#Static Routes: 157
Beego: 97944 Bytes
Chi: 82432 Bytes
Gin: 30448 Bytes
GocraftWeb: 55720 Bytes
Goji: 27200 Bytes
GorillaMux: 588576 Bytes
HttpRouter: 21128 Bytes
Martini: 310832 Bytes
=== RUN TestRouters
--- PASS: TestRouters (1.01s)
goos: darwin
goarch: amd64
pkg: github.com/pkieltyka/go-http-routing-benchmark
BenchmarkBeego_Param 200000 7392 ns/op 1728 B/op 25 allocs/op
BenchmarkChi_Param 1000000 1012 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param 30000000 59.6 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param 1000000 1667 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_Param 2000000 832 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param 500000 3242 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_Param 20000000 93.3 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_Param 300000 5021 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Param5 200000 7686 ns/op 1776 B/op 25 allocs/op
BenchmarkChi_Param5 1000000 1126 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param5 20000000 105 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param5 1000000 2389 ns/op 920 B/op 11 allocs/op
BenchmarkGoji_Param5 2000000 897 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param5 300000 4005 ns/op 1344 B/op 10 allocs/op
BenchmarkHttpRouter_Param5 5000000 327 ns/op 160 B/op 1 allocs/op
BenchmarkMartini_Param5 300000 5958 ns/op 1232 B/op 11 allocs/op
BenchmarkBeego_Param20 200000 9337 ns/op 1968 B/op 25 allocs/op
BenchmarkChi_Param20 1000000 1977 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Param20 5000000 256 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param20 200000 9644 ns/op 3795 B/op 15 allocs/op
BenchmarkGoji_Param20 500000 3142 ns/op 1247 B/op 2 allocs/op
BenchmarkGorillaMux_Param20 200000 9132 ns/op 3451 B/op 12 allocs/op
BenchmarkHttpRouter_Param20 1000000 1439 ns/op 640 B/op 1 allocs/op
BenchmarkMartini_Param20 100000 11680 ns/op 3596 B/op 13 allocs/op
BenchmarkBeego_ParamWrite 200000 7042 ns/op 1736 B/op 26 allocs/op
BenchmarkChi_ParamWrite 1000000 1077 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParamWrite 20000000 117 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParamWrite 1000000 1702 ns/op 656 B/op 9 allocs/op
BenchmarkGoji_ParamWrite 2000000 876 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParamWrite 500000 3283 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_ParamWrite 10000000 127 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_ParamWrite 300000 5569 ns/op 1176 B/op 14 allocs/op
BenchmarkBeego_GithubStatic 200000 7126 ns/op 1728 B/op 25 allocs/op
BenchmarkChi_GithubStatic 1000000 1051 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GithubStatic 20000000 84.4 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubStatic 2000000 782 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_GithubStatic 10000000 190 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GithubStatic 100000 13342 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_GithubStatic 30000000 43.4 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GithubStatic 100000 13038 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GithubParam 200000 6166 ns/op 1872 B/op 25 allocs/op
BenchmarkChi_GithubParam 2000000 832 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GithubParam 10000000 128 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubParam 1000000 1303 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GithubParam 2000000 858 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GithubParam 200000 8437 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_GithubParam 10000000 206 ns/op 96 B/op 1 allocs/op
BenchmarkMartini_GithubParam 200000 9804 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_GithubAll 1000 1256118 ns/op 369523 B/op 5075 allocs/op
BenchmarkChi_GithubAll 10000 171943 ns/op 87697 B/op 609 allocs/op
BenchmarkGin_GithubAll 50000 26761 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubAll 10000 263245 ns/op 131656 B/op 1686 allocs/op
BenchmarkGoji_GithubAll 5000 385650 ns/op 56113 B/op 334 allocs/op
BenchmarkGorillaMux_GithubAll 300 4787407 ns/op 251648 B/op 1994 allocs/op
BenchmarkHttpRouter_GithubAll 50000 38416 ns/op 13792 B/op 167 allocs/op
BenchmarkMartini_GithubAll 300 4472417 ns/op 226550 B/op 2325 allocs/op
BenchmarkBeego_GPlusStatic 300000 5445 ns/op 1699 B/op 25 allocs/op
BenchmarkChi_GPlusStatic 3000000 491 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlusStatic 20000000 63.9 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusStatic 3000000 490 ns/op 280 B/op 5 allocs/op
BenchmarkGoji_GPlusStatic 10000000 153 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GPlusStatic 1000000 1249 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_GPlusStatic 50000000 25.9 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GPlusStatic 500000 3651 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GPlusParam 300000 5577 ns/op 1792 B/op 25 allocs/op
BenchmarkChi_GPlusParam 3000000 546 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlusParam 20000000 82.9 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusParam 2000000 882 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_GPlusParam 3000000 537 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlusParam 500000 2701 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_GPlusParam 10000000 121 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlusParam 300000 4400 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_GPlus2Params 300000 5764 ns/op 1920 B/op 25 allocs/op
BenchmarkChi_GPlus2Params 2000000 621 ns/op 432 B/op 3 allocs/op
BenchmarkGin_GPlus2Params 20000000 96.8 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlus2Params 1000000 1075 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GPlus2Params 2000000 777 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlus2Params 200000 6051 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_GPlus2Params 10000000 145 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlus2Params 200000 9505 ns/op 1200 B/op 13 allocs/op
BenchmarkBeego_GPlusAll 20000 73270 ns/op 23611 B/op 325 allocs/op
BenchmarkChi_GPlusAll 200000 7798 ns/op 5616 B/op 39 allocs/op
BenchmarkGin_GPlusAll 1000000 1089 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusAll 100000 12282 ns/op 8040 B/op 103 allocs/op
BenchmarkGoji_GPlusAll 200000 7400 ns/op 3696 B/op 22 allocs/op
BenchmarkGorillaMux_GPlusAll 30000 43429 ns/op 16112 B/op 128 allocs/op
BenchmarkHttpRouter_GPlusAll 1000000 1511 ns/op 640 B/op 11 allocs/op
BenchmarkMartini_GPlusAll 20000 75188 ns/op 14016 B/op 145 allocs/op
BenchmarkBeego_ParseStatic 300000 5395 ns/op 1712 B/op 25 allocs/op
BenchmarkChi_ParseStatic 3000000 500 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParseStatic 20000000 63.0 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseStatic 3000000 530 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_ParseStatic 10000000 199 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_ParseStatic 1000000 1962 ns/op 976 B/op 9 allocs/op
BenchmarkHttpRouter_ParseStatic 50000000 27.4 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_ParseStatic 500000 3930 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_ParseParam 300000 5457 ns/op 1776 B/op 25 allocs/op
BenchmarkChi_ParseParam 3000000 526 ns/op 432 B/op 3 allocs/op
BenchmarkGin_ParseParam 20000000 70.7 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseParam 2000000 911 ns/op 664 B/op 8 allocs/op
BenchmarkGoji_ParseParam 3000000 595 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParseParam 1000000 2166 ns/op 1280 B/op 10 allocs/op
BenchmarkHttpRouter_ParseParam 20000000 108 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_ParseParam 300000 4360 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Parse2Params 300000 5656 ns/op 1824 B/op 25 allocs/op
BenchmarkChi_Parse2Params 3000000 577 ns/op 432 B/op 3 allocs/op
BenchmarkGin_Parse2Params 20000000 82.9 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Parse2Params 1000000 1058 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_Parse2Params 3000000 568 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Parse2Params 1000000 2421 ns/op 1296 B/op 10 allocs/op
BenchmarkHttpRouter_Parse2Params 10000000 120 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_Parse2Params 300000 4345 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_ParseAll 10000 143156 ns/op 46103 B/op 650 allocs/op
BenchmarkChi_ParseAll 100000 14826 ns/op 11232 B/op 78 allocs/op
BenchmarkGin_ParseAll 1000000 1935 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseAll 100000 21876 ns/op 13728 B/op 181 allocs/op
BenchmarkGoji_ParseAll 100000 12096 ns/op 5376 B/op 32 allocs/op
BenchmarkGorillaMux_ParseAll 20000 83291 ns/op 30288 B/op 250 allocs/op
BenchmarkHttpRouter_ParseAll 1000000 1988 ns/op 640 B/op 16 allocs/op
BenchmarkMartini_ParseAll 10000 119744 ns/op 25072 B/op 253 allocs/op
BenchmarkBeego_StaticAll 2000 871838 ns/op 279436 B/op 3925 allocs/op
BenchmarkChi_StaticAll 20000 93250 ns/op 67824 B/op 471 allocs/op
BenchmarkGin_StaticAll 100000 17729 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_StaticAll 20000 92184 ns/op 46440 B/op 785 allocs/op
BenchmarkGoji_StaticAll 30000 41678 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_StaticAll 1000 1232177 ns/op 153328 B/op 1421 allocs/op
BenchmarkHttpRouter_StaticAll 200000 10166 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_StaticAll 1000 1982744 ns/op 125442 B/op 1717 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 235.247s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment