Closed adambrett closed 7 years ago
Hi @adambrett. Thanks for taking the time to check this out!
Your router is extremely interesting, though, as you stated since it cannot be cached and must be "built" each time it doesn't quite fit with the existing tests. The implementation might, however, offer some potential advantages that the others do not. I really like the idea of a complete, perhaps even un-optimized (ie. we remove the symfony2 optimized test from this benchmark) benchmark.
What I've done is I've heavily refactored how the benchmarks are setup, and I added support for multiple benchmarks using a BenchmarkCollection
. If you have some time, check out the latest changes in master. Hopefully the changes I've made will help make the project more maintainable, and more importantly, allow us to create multiple benchmarks and have them exist simultaneously.
I would love it if you wanted to add a third, new benchmark that tests the complete operation from start to finish for each router, but even if not, thanks for contributing!
Thanks, I'll take a look over the next couple of days and see what I can do.
Hi,
I originally just wanted to test adding my little router package to see how it compared, but when it totally blew all the others away I knew something was wrong because I wrote mine with absolutely no consideration for speed.
A bit on investigation showed that the issue was the way in which things are dispatched, and that my router does the matching when routes are added, and then discards anything else immediately. That lead me to the conclusion that a fairer comparison is the assembly of the router as well as dispatch process, that lead to the following figures:
Clearly this still isn't right, as FastRoute should be far faster than my package, which lead me to separate out the Dumped Symfony2 router, and write some rudimentary caching for the other routes (so the impact of building the router becomes negligible), which lead to the following figures:
As the way my router is designed means it's impossible to cache I have left it uncached. I suspect that Symfony comes out so much faster because it's writing a PHP class rather than serializing and unserializing the router object.
I guess this shows a few things:
1) The rankings are slightly different from the original benchmark because the way routes are assembled has an impact 2) It's important to cache your router in production