noodlehaus/dispatch

Dispatch 10.2 seems really slow

bmcminn opened this issue · 2 comments

Running Dispatch in my local dev environment using PHP's built-in server causes ~1+sec of latency to the page response. Just switched a few of my routes over to https://github.com/bramus/router and now I'm seeing page response times on those routes of ~330-560ms.

The only change I made was the router library running things, everything else in my app, IO, DB, template rendering, etc was unchanged.

I'll see about coming up with a couple of test cases to validate this, but I'm curiuos if Dispatch's internal route management is just inheritely inefficient?

The routing approach has changed with the use of closures, and the route matching loop invokes closures that contain the matching logic. This might be the main cause for this. Currently working on this to move out that logic to the top level loop.

I've tested the before and after of #87, and got the following results:

Before
Screenshot 2023-03-29 at 9 41 21 PM

After
Screenshot 2023-03-29 at 9 48 47 PM

I think the results are inconclusive, and could be attributed to margin of error. This was using php-cli's built in server, and 10 test routes.

Will be closing this, and we can revisit again if it's still an issue.