-
Notifications
You must be signed in to change notification settings - Fork 70
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
Benchmark is not (only) measuring the routing cost #24
Comments
@julienschmidt thanks your suggest. i try to modify my benchmark code does the following:
benchmark result:
right now? Could you give me any other advice? |
Take a look at https://github.com/julienschmidt/go-http-routing-benchmark/blob/2b136956a56bc65dddfa4bdaf7d1728ae2c90d50/bench_test.go#L76 Btw: I don't mind if you copy some of the benchmark code, but please add proper attribution. The |
@julienschmidt thanks your suggest.you are awesome . i try to modify my benchmark code again:
benchmark result:
BTW why should set these other attributes properly too. could you tell me the reason? |
@xujiajun Mby it would be nice to include github.com/husobee/vestigo since it's a stand alone url router which is std lib compatible like your young project. Mby you can get some inspiration from it. |
@negbie thanks your suggest. |
@julienschmidt i have updated the REDME about benchmark: https://github.com/xujiajun/gorouter#benchmarks, any other advice? |
I think the benchmark looks fine now. I'm closing this issue, as the benchmark is fixed now. |
Currently your benchmark code does the following:
The critical part is the
router.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest(route.method, route.path, nil))
within the loop, meaning that you allocate and initialize a new Recorder and a Request in every loop iteration.Unfortunately that is likely much more expensive than the actual routing, meaning that both the measured memory cost and the execution time are completely meaningless, since there is a huge baseline cost.
The text was updated successfully, but these errors were encountered: