DASPRiD / Dash

Flexible PSR-7 compliant HTTP router
BSD 2-Clause "Simplified" License
29 stars 9 forks source link

Faster sorting #9

Closed bakura10 closed 10 years ago

bakura10 commented 10 years ago

Here: https://github.com/DASPRiD/Dash/blob/master/src/Dash/Mvc/Router/Http/RouteCollection/RouteCollection.php#L113

You are using uasort but it's pretty slow. I think you can reorder those lines: https://github.com/DASPRiD/Dash/blob/master/src/Dash/Mvc/Router/Http/RouteCollection/RouteCollection.php#L66

so that priority comes first, then serial, then route. This way you can directly use sort without having to rely on a custom method.

DASPRiD commented 10 years ago

I'll try that out after finishing the unit tests. The idea sounds indeed interesting.

bakura10 commented 10 years ago

(In fact I played a loooot with sorting for the event manager rewrite... using a custom method for sorting was so slower I cannot tell you how much: around 0,45 s without custom method, and execution timeout using custom function, so it's at the minimum 60 times slower).