Skip to content

Instantly share code, notes, and snippets.

@pkieltyka
Last active January 8, 2017 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkieltyka/d0814d5396c996cb3ff8076399583d1f to your computer and use it in GitHub Desktop.
Save pkieltyka/d0814d5396c996cb3ff8076399583d1f to your computer and use it in GitHub Desktop.
##
## HTTP Router benchmarks -- Jan 7th, 2017 running Go 1.8beta2
##
## 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: 77992 Bytes
#GPlusAPI Routes: 13
Chi: 7208 Bytes
#ParseAPI Routes: 26
Chi: 7888 Bytes
#Static Routes: 157
Chi: 78416 Bytes
=== RUN TestRouters
--- PASS: TestRouters (0.85s)
BenchmarkChi_Param 3000000 380 ns/op 304 B/op 2 allocs/op
BenchmarkChi_Param5 3000000 528 ns/op 304 B/op 2 allocs/op
BenchmarkChi_Param20 1000000 1183 ns/op 304 B/op 2 allocs/op
BenchmarkChi_ParamWrite 3000000 436 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GithubStatic 3000000 408 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GithubParam 3000000 568 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GithubAll 10000 114835 ns/op 61716 B/op 406 allocs/op
BenchmarkChi_GPlusStatic 5000000 369 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GPlusParam 3000000 403 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GPlus2Params 3000000 472 ns/op 304 B/op 2 allocs/op
BenchmarkChi_GPlusAll 200000 5920 ns/op 3952 B/op 26 allocs/op
BenchmarkChi_ParseStatic 5000000 404 ns/op 304 B/op 2 allocs/op
BenchmarkChi_ParseParam 3000000 432 ns/op 304 B/op 2 allocs/op
BenchmarkChi_Parse2Params 3000000 462 ns/op 304 B/op 2 allocs/op
BenchmarkChi_ParseAll 200000 11948 ns/op 7904 B/op 52 allocs/op
BenchmarkChi_StaticAll 20000 77206 ns/op 47731 B/op 314 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 30.451s
[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: 144664 Bytes
Chi: 77992 Bytes
Gin: 52480 Bytes
GocraftWeb: 95432 Bytes
Goji: 86088 Bytes
GorillaMux: 1502976 Bytes
HttpRouter: 37464 Bytes
Martini: 564352 Bytes
#GPlusAPI Routes: 13
Beego: 9840 Bytes
Chi: 7208 Bytes
Gin: 3856 Bytes
GocraftWeb: 7496 Bytes
Goji: 2912 Bytes
GorillaMux: 71072 Bytes
HttpRouter: 2712 Bytes
Martini: 23936 Bytes
#ParseAPI Routes: 26
Beego: 18544 Bytes
Chi: 7888 Bytes
Gin: 6816 Bytes
GocraftWeb: 12800 Bytes
Goji: 5232 Bytes
GorillaMux: 122184 Bytes
HttpRouter: 4976 Bytes
Martini: 45952 Bytes
#Static Routes: 157
Beego: 93896 Bytes
Chi: 78416 Bytes
Gin: 30400 Bytes
GocraftWeb: 55304 Bytes
Goji: 27200 Bytes
GorillaMux: 670544 Bytes
HttpRouter: 21128 Bytes
Martini: 310832 Bytes
=== RUN TestRouters
--- PASS: TestRouters (0.96s)
BenchmarkBeego_Param 200000 5970 ns/op 1778 B/op 29 allocs/op
BenchmarkChi_Param 2000000 556 ns/op 304 B/op 2 allocs/op
BenchmarkGin_Param 20000000 59.9 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param 1000000 1422 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_Param 2000000 681 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param 1000000 2618 ns/op 1056 B/op 11 allocs/op
BenchmarkHttpRouter_Param 20000000 85.4 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_Param 300000 4624 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Param5 200000 6346 ns/op 1830 B/op 29 allocs/op
BenchmarkChi_Param5 2000000 731 ns/op 304 B/op 2 allocs/op
BenchmarkGin_Param5 20000000 97.8 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param5 500000 2306 ns/op 920 B/op 11 allocs/op
BenchmarkGoji_Param5 2000000 890 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Param5 300000 3764 ns/op 1184 B/op 11 allocs/op
BenchmarkHttpRouter_Param5 5000000 313 ns/op 160 B/op 1 allocs/op
BenchmarkMartini_Param5 200000 5458 ns/op 1232 B/op 11 allocs/op
BenchmarkBeego_Param20 200000 8315 ns/op 2024 B/op 29 allocs/op
BenchmarkChi_Param20 1000000 1260 ns/op 304 B/op 2 allocs/op
BenchmarkGin_Param20 5000000 259 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Param20 200000 9286 ns/op 3796 B/op 15 allocs/op
BenchmarkGoji_Param20 500000 3084 ns/op 1247 B/op 2 allocs/op
BenchmarkGorillaMux_Param20 200000 9299 ns/op 3548 B/op 13 allocs/op
BenchmarkHttpRouter_Param20 1000000 1318 ns/op 640 B/op 1 allocs/op
BenchmarkMartini_Param20 100000 10137 ns/op 3596 B/op 13 allocs/op
BenchmarkBeego_ParamWrite 200000 6115 ns/op 1792 B/op 30 allocs/op
BenchmarkChi_ParamWrite 2000000 575 ns/op 304 B/op 2 allocs/op
BenchmarkGin_ParamWrite 10000000 123 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParamWrite 1000000 1629 ns/op 656 B/op 9 allocs/op
BenchmarkGoji_ParamWrite 2000000 714 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParamWrite 500000 2651 ns/op 1064 B/op 12 allocs/op
BenchmarkHttpRouter_ParamWrite 10000000 118 ns/op 32 B/op 1 allocs/op
BenchmarkMartini_ParamWrite 300000 5034 ns/op 1176 B/op 14 allocs/op
BenchmarkBeego_GithubStatic 200000 6709 ns/op 1779 B/op 29 allocs/op
BenchmarkChi_GithubStatic 2000000 663 ns/op 304 B/op 2 allocs/op
BenchmarkGin_GithubStatic 20000000 72.3 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubStatic 2000000 776 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_GithubStatic 10000000 214 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GithubStatic 100000 15116 ns/op 736 B/op 10 allocs/op
BenchmarkHttpRouter_GithubStatic 30000000 41.1 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GithubStatic 100000 12441 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GithubParam 300000 5743 ns/op 1925 B/op 29 allocs/op
BenchmarkChi_GithubParam 3000000 541 ns/op 304 B/op 2 allocs/op
BenchmarkGin_GithubParam 10000000 121 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubParam 1000000 1323 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GithubParam 2000000 852 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GithubParam 200000 8129 ns/op 1088 B/op 11 allocs/op
BenchmarkHttpRouter_GithubParam 10000000 193 ns/op 96 B/op 1 allocs/op
BenchmarkMartini_GithubParam 200000 9898 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_GithubAll 1000 1142417 ns/op 380234 B/op 5887 allocs/op
BenchmarkChi_GithubAll 10000 114334 ns/op 61713 B/op 406 allocs/op
BenchmarkGin_GithubAll 50000 23939 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GithubAll 10000 268389 ns/op 131656 B/op 1686 allocs/op
BenchmarkGoji_GithubAll 5000 397788 ns/op 56113 B/op 334 allocs/op
BenchmarkGorillaMux_GithubAll 300 5060789 ns/op 211840 B/op 2272 allocs/op
BenchmarkHttpRouter_GithubAll 50000 35531 ns/op 13792 B/op 167 allocs/op
BenchmarkMartini_GithubAll 500 3877764 ns/op 226551 B/op 2325 allocs/op
BenchmarkBeego_GPlusStatic 300000 4534 ns/op 1748 B/op 29 allocs/op
BenchmarkChi_GPlusStatic 5000000 308 ns/op 304 B/op 2 allocs/op
BenchmarkGin_GPlusStatic 20000000 61.6 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusStatic 3000000 469 ns/op 280 B/op 5 allocs/op
BenchmarkGoji_GPlusStatic 10000000 149 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_GPlusStatic 1000000 1073 ns/op 736 B/op 10 allocs/op
BenchmarkHttpRouter_GPlusStatic 50000000 25.6 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_GPlusStatic 500000 3400 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_GPlusParam 300000 5117 ns/op 1844 B/op 29 allocs/op
BenchmarkChi_GPlusParam 5000000 347 ns/op 304 B/op 2 allocs/op
BenchmarkGin_GPlusParam 20000000 79.8 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusParam 2000000 850 ns/op 648 B/op 8 allocs/op
BenchmarkGoji_GPlusParam 3000000 513 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlusParam 500000 2672 ns/op 1056 B/op 11 allocs/op
BenchmarkHttpRouter_GPlusParam 10000000 130 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlusParam 300000 4406 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_GPlus2Params 300000 4993 ns/op 1973 B/op 29 allocs/op
BenchmarkChi_GPlus2Params 3000000 418 ns/op 304 B/op 2 allocs/op
BenchmarkGin_GPlus2Params 20000000 104 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlus2Params 1000000 1154 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_GPlus2Params 2000000 778 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_GPlus2Params 200000 6373 ns/op 1088 B/op 11 allocs/op
BenchmarkHttpRouter_GPlus2Params 10000000 150 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_GPlus2Params 200000 9773 ns/op 1200 B/op 13 allocs/op
BenchmarkBeego_GPlusAll 20000 63471 ns/op 24257 B/op 377 allocs/op
BenchmarkChi_GPlusAll 300000 5184 ns/op 3952 B/op 26 allocs/op
BenchmarkGin_GPlusAll 1000000 1069 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_GPlusAll 100000 13316 ns/op 8040 B/op 103 allocs/op
BenchmarkGoji_GPlusAll 200000 7176 ns/op 3696 B/op 22 allocs/op
BenchmarkGorillaMux_GPlusAll 50000 39538 ns/op 13296 B/op 142 allocs/op
BenchmarkHttpRouter_GPlusAll 1000000 1507 ns/op 640 B/op 11 allocs/op
BenchmarkMartini_GPlusAll 20000 72676 ns/op 14016 B/op 145 allocs/op
BenchmarkBeego_ParseStatic 300000 4655 ns/op 1761 B/op 29 allocs/op
BenchmarkChi_ParseStatic 5000000 336 ns/op 304 B/op 2 allocs/op
BenchmarkGin_ParseStatic 20000000 58.8 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseStatic 3000000 509 ns/op 296 B/op 5 allocs/op
BenchmarkGoji_ParseStatic 10000000 193 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_ParseStatic 1000000 1841 ns/op 752 B/op 11 allocs/op
BenchmarkHttpRouter_ParseStatic 50000000 27.0 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_ParseStatic 300000 3735 ns/op 768 B/op 9 allocs/op
BenchmarkBeego_ParseParam 300000 4685 ns/op 1825 B/op 29 allocs/op
BenchmarkChi_ParseParam 5000000 332 ns/op 304 B/op 2 allocs/op
BenchmarkGin_ParseParam 20000000 64.1 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseParam 2000000 889 ns/op 664 B/op 8 allocs/op
BenchmarkGoji_ParseParam 3000000 541 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_ParseParam 1000000 2127 ns/op 1088 B/op 12 allocs/op
BenchmarkHttpRouter_ParseParam 20000000 106 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_ParseParam 500000 4152 ns/op 1072 B/op 10 allocs/op
BenchmarkBeego_Parse2Params 300000 5011 ns/op 1875 B/op 29 allocs/op
BenchmarkChi_Parse2Params 3000000 361 ns/op 304 B/op 2 allocs/op
BenchmarkGin_Parse2Params 20000000 75.6 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_Parse2Params 1000000 1068 ns/op 712 B/op 9 allocs/op
BenchmarkGoji_Parse2Params 3000000 547 ns/op 336 B/op 2 allocs/op
BenchmarkGorillaMux_Parse2Params 1000000 2281 ns/op 1088 B/op 11 allocs/op
BenchmarkHttpRouter_Parse2Params 10000000 117 ns/op 64 B/op 1 allocs/op
BenchmarkMartini_Parse2Params 500000 4337 ns/op 1152 B/op 11 allocs/op
BenchmarkBeego_ParseAll 10000 126310 ns/op 47394 B/op 754 allocs/op
BenchmarkChi_ParseAll 200000 9914 ns/op 7904 B/op 52 allocs/op
BenchmarkGin_ParseAll 1000000 1887 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_ParseAll 100000 22935 ns/op 13728 B/op 181 allocs/op
BenchmarkGoji_ParseAll 200000 11631 ns/op 5376 B/op 32 allocs/op
BenchmarkGorillaMux_ParseAll 20000 80746 ns/op 24864 B/op 292 allocs/op
BenchmarkHttpRouter_ParseAll 1000000 1910 ns/op 640 B/op 16 allocs/op
BenchmarkMartini_ParseAll 10000 113185 ns/op 25072 B/op 253 allocs/op
BenchmarkBeego_StaticAll 2000 786227 ns/op 287798 B/op 4553 allocs/op
BenchmarkChi_StaticAll 20000 65125 ns/op 47728 B/op 314 allocs/op
BenchmarkGin_StaticAll 100000 16413 ns/op 0 B/op 0 allocs/op
BenchmarkGocraftWeb_StaticAll 20000 91093 ns/op 46440 B/op 785 allocs/op
BenchmarkGoji_StaticAll 30000 44939 ns/op 0 B/op 0 allocs/op
BenchmarkGorillaMux_StaticAll 1000 1248807 ns/op 115648 B/op 1578 allocs/op
BenchmarkHttpRouter_StaticAll 200000 10012 ns/op 0 B/op 0 allocs/op
BenchmarkMartini_StaticAll 1000 1796896 ns/op 125442 B/op 1717 allocs/op
PASS
ok github.com/pkieltyka/go-http-routing-benchmark 228.538s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment