New benchmark: Mezon Router is up to 222 times faster than Steampixel Router

Dodonov Alexey
3 min readMay 24, 2021

--

Hi all! Today we have one more benchmark.

As usual we have two cases:

  1. http server accepts request, launches php script, which handles this request, and then all script data is removed from memory. All following requests are processed in the same way. In this case very critical to launch script as soon as possible and we do not have time for long pre-compilations and preparations. Because all of it will be lost after the script will finish working;
  2. php script is launching, initiating all internal components (and router is one of them) and then starting processing requests. This case can be organized via for example react-php. It differs from the previous case because we can spend reasonable time to pre-compile routes for faster processing.

The first case

RouteGenerator::generateSteampixelStaticRoutes(1000);
\Steampixel\Route::run('/static/0');
RouteGenerator::generateSteampixelStaticRoutes(1000);
\Steampixel\Route::run('/static/99');
RouteGenerator::generateSteampixelStaticRoutes(1000);
\Steampixel\Route::run('/static/199');
// and so on up to /static/999 route
RouteGenerator::generateSteampixelNonStaticRoutes(1000);
\Steampixel\Route::run('/param/0/1');
RouteGenerator::generateSteampixelNonStaticRoutes(1000);
\Steampixel\Route::run('/param/99/1');
RouteGenerator::generateSteampixelNonStaticRoutes(1000);
\Steampixel\Route::run('/param/199/1');
// and so on up to /param/999/1 route

The second case

RouteGenerator::generateSteampixelNonStaticRoutes(1000);
\Steampixel\Route::run('/static/0');
\Steampixel\Route::run('/static/99');\Steampixel\Route::run('/static/199');
// and so on up to /static/999 route
RouteGenerator::generateSteampixelNonStaticRoutes(1000);
\Steampixel\Route::run('/param/0/1');
\Steampixel\Route::run('/param/99/1');\Steampixel\Route::run('/param/199/1');
// and so on up to /param/999/1 route

OK What do we have?

The first case + static routes

+------------------------------------+--------+
| benchmark | diff |
+------------------------------------+--------+
| CoffeeSingleRequestStaticBench | 4.85x |
| DVKSingleRequestStaticBench | 2.99x |
| HoaSingleRequestStaticBench | 4.71x |
| MezonSingleRequestStaticBench | 1.00x |
| PeceeSingleRequestStaticBench | 3.84x |
| SteampixelSingleRequestStaticBench | 21.14x |
+------------------------------------+--------+

The first case + non-static routes

+---------------------------+--------+
| benchmark | diff |
+---------------------------+--------+
| CoffeeReactParamBench | 7.57x |
| DVKReactParamBench | 13.91x |
| HoaReactParamBench | 3.69x |
| MezonReactParamBench | 1.00x |
| PeceeReactParamBench | 41.28x |
| SteampixelReactParamBench | 16.72x |
+---------------------------+--------+

The second case + static routes

+----------------------------+------------+
| benchmark | diff |
+----------------------------+------------+
| CoffeeReactStaticBench | 416.02x |
| DVKReactStaticBench | 537.30x |
| HoaReactStaticBench | 187.21x |
| MezonReactStaticBench | 1.00x |
| PeceeReactStaticBench | 989.82x |
| SteampixelReactParamBench | 221.61x |
+----------------------------+------------+

The second case + non-static routes

+-----------------------------------+-------+
| benchmark | diff |
+-----------------------------------+-------+
| CoffeeSingleRequestParamBench | 1.77x |
| DVKSingleRequestParamBench | 1.00x |
| HoaSingleRequestParamBench | 1.56x |
| MezonSingleRequestParamBench | 4.27x |
| PeceeSingleRequestParamBench | 2.52x |
| SteampixelSingleRequestParamBench | 7.86x |
+-----------------------------------+-------+

What’s next?

More articles can be found in my Twitter

What is mezon/router?

mezon/router now is:

  • framework for routing with 100% code coverage
  • 10.0 points on scrutinizer-ci.com
  • router is a part of the Mezon Project

Repo on github.com: https://github.com/alexdodonov/mezon-router

It will be great if you will contribute something to this project. Documentation, sharing the project in your social media, bug fixing, refactoring, or even submitting issue with question or feature request. Thanks anyway )

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response