{
    "href": "/post/2021/07/27/autoroute-is-3x-faster-than-fastroute/",
    "relId": "2021/07/27/autoroute-is-3x-faster-than-fastroute",
    "title": "AutoRoute is 3x Faster Than FastRoute",
    "author": "pmjones",
    "tags": [
        {
            "href": "/tag/programming/",
            "relId": "programming",
            "title": "Programming",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/autoroute/",
            "relId": "autoroute",
            "title": "Autoroute",
            "author": null,
            "created": "2021-07-27 14:02:36 UTC",
            "updated": [
                "2021-07-27 14:02:36 UTC"
            ],
            "markup": "markdown"
        }
    ],
    "created": "2021-07-27 14:02:36 UTC",
    "updated": [
        "2021-07-27 14:02:36 UTC"
    ],
    "markup": "markdown",
    "html": "<p>When I first published <a href=\"https://github.com/pmjones/AutoRoute\">AutoRoute</a> in April 2019, I benchmarked it out of habit, to see how it compared to the fastest routing system I knew, <a href=\"https://github.com/nikic/FastRoute\">FastRoute</a>. The <a href=\"https://github.com/pmjones/AutoRoute-benchmark/tree/db0e3c29cbe574ccb82433281fca7cba62d5459a\">benchmark results at that time</a> typically looked like this on PHP 7.2:</p>\n<pre><code>AutoRoute Runtime: 0.11443305015564\nFastRoute Runtime: 1.9010598659515\nFastRoute Cached:  0.12522411346436\n</code></pre>\n<p>It turned out that AutoRoute was very slightly faster than FastRoute; I was pleased, but surprised. Getting anywhere close to FastRoute was enough for me.</p>\n<p>Lately, though, I've been working on the 2.x version of AutoRoute, and I compared 2.x to the 1.x benchmark. I was very unhappy with the results: 2.x was something like 6x slower than 1.x. While investigating the causes, I noticed that I had XDebug turned on. Turning it off brought the comparative benchmark to something much more reasonable.</p>\n<p>It turns out that I made the same oversight when benchmarking 1.x against FastRoute, so I have corrected my error and updated the <a href=\"https://github.com/pmjones/AutoRoute-benchmark\">1.x AutoRoute benchmarks</a>. I am even more surprised now: the scenario reports that AutoRoute is about 3x faster than FastRoute:</p>\n<pre><code>AutoRoute Runtime: 0.027965068817139\nFastRoute Runtime: 0.21157002449036\nFastRoute Cached:  0.10321187973022\n</code></pre>\n<p>Now, remember: routing is only a tiny part of your overall application performance. Using AutoRoute over FastRoute will not triple the speed of your applications. Still, it is satisfying to find better performance where you can.</p>\n"
}
