Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue in PR (#1391) #2350

Closed
appleboy opened this issue May 3, 2020 · 0 comments · Fixed by #2351
Closed

Performance issue in PR (#1391) #2350

appleboy opened this issue May 3, 2020 · 0 comments · Fixed by #2351
Assignees

Comments

@appleboy
Copy link
Member

appleboy commented May 3, 2020

#1391 trigger the performance issue.

benchmark:

pkg: github.com/julienschmidt/go-http-routing-benchmark
BenchmarkEcho_Param        	13535522	        88.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param         	 5361892	       238 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_Param5       	 5008866	       244 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param5        	 4290758	       272 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_Param20      	 1641387	       760 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param20       	 2317610	       521 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_ParamWrite   	 5904582	       203 ns/op	       8 B/op	       1 allocs/op
BenchmarkGin_ParamWrite    	 4513596	       267 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GithubStatic 	 9554672	       144 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubStatic  	 4920577	       246 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GithubParam  	 4610731	       246 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubParam   	 4571893	       338 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GithubAll    	   22447	     55123 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubAll     	   18040	     65561 ns/op	    6496 B/op	     203 allocs/op
BenchmarkEcho_GPlusStatic  	12387967	        87.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusStatic   	 5539902	       230 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GPlusParam   	 8484045	       136 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusParam    	 4628140	       257 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GPlus2Params 	 5794423	       209 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlus2Params  	 4435572	       260 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_GPlusAll     	  567093	      2104 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusAll      	  327002	      3349 ns/op	     416 B/op	      13 allocs/op
BenchmarkEcho_ParseStatic  	13683361	        88.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseStatic   	 5690004	       218 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_ParseParam   	11511034	       109 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseParam    	 5031255	       247 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_Parse2Params 	 7868221	       152 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Parse2Params  	 4861460	       261 ns/op	      32 B/op	       1 allocs/op
BenchmarkEcho_ParseAll     	  318800	      3533 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseAll      	  230422	      6377 ns/op	     832 B/op	      26 allocs/op
BenchmarkEcho_StaticAll    	   40495	     29597 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_StaticAll     	   29606	     42596 ns/op	    5024 B/op	     157 allocs/op

Without #1391 commit:

pkg: github.com/julienschmidt/go-http-routing-benchmark
BenchmarkEcho_Param        	13765762	        88.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param         	16475670	        78.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_Param5       	 5095788	       239 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param5        	 8914904	       135 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_Param20      	 1580520	       759 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Param20       	 3694677	       321 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_ParamWrite   	 6190405	       204 ns/op	       8 B/op	       1 allocs/op
BenchmarkGin_ParamWrite    	 7506909	       151 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GithubStatic 	 9014336	       130 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubStatic  	10326368	       123 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GithubParam  	 4447852	       279 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubParam   	 6891337	       174 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GithubAll    	   25905	     46867 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubAll     	   36128	     32502 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GPlusStatic  	13771851	        88.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusStatic   	16447762	        78.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GPlusParam   	 8797988	       133 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusParam    	11276586	       106 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GPlus2Params 	 5849034	       201 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlus2Params  	 9059781	       131 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_GPlusAll     	  596871	      1998 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GPlusAll      	  732151	      1584 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_ParseStatic  	12376551	       128 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseStatic   	10699678	       106 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_ParseParam   	 9799104	       127 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseParam    	13203855	       127 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_Parse2Params 	 6864175	       184 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_Parse2Params  	10904766	       122 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_ParseAll     	  260600	      4147 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_ParseAll      	  378186	      2756 ns/op	       0 B/op	       0 allocs/op
BenchmarkEcho_StaticAll    	   30274	     34241 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_StaticAll     	   37824	     28181 ns/op	       0 B/op	       0 allocs/op

How to test

git clone https://github.com/appleboy/go-http-routing-benchmark.git
# performance issue
go test -bench="Gin|Echo"
# without performance
go get github.com/gin-gonic/gin@67008be35f5432aeec06641540f3b6df3eac8747
go test -bench="Gin|Echo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants