Hi all! Today we have one more benchmark.

As usual we have two cases:

The first case

// static routes
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/0';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/99';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/199';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
// and so on up to /static/999 route
// non static routes
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/0/1';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/99/1';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/199/1';
$routes = RouteGenerator::generateToroStaticRoutes(1000);
\Toro::serve($routes);
// and so on up to /param/999/1 route

The second case

// static routes
$routes = RouteGenerator::generateToroStaticRoutes(1000);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/0';
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/99';
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/static/199';
\Toro::serve($routes);
// and so on up to /static/999 route
// non static routes
$routes = RouteGenerator::generateToroStaticRoutes(1000);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/0/1/';
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/99/1/';
\Toro::serve($routes);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/param/199/1/';
\Toro::serve($routes);
// and so on up to /param/999/1 route

OK What do we have?

The first case + static routes

+------------------------------------+---------+
| benchmark | diff |
+------------------------------------+---------+
| CoffeeSingleRequestStaticBench | 32.80x |
| DVKSingleRequestStaticBench | 15.50x |
| HoaSingleRequestStaticBench | 27.35x |
| IBSingleRequestStaticBench | 71.28x |
| MezonSingleRequestStaticBench | 5.14x |
| MiladSingleRequestStaticBench | 16.50x |
| PeceeSingleRequestStaticBench | 23.04x |
| PowerSingleRequestStaticBench | 10.98x |
| SteampixelSingleRequestStaticBench | 132.75x |
| ToroSingleRequestStaticBench | 1.00x |
+------------------------------------+---------+

The first case + non-static routes

+-----------------------------------+--------+
| benchmark | diff |
+-----------------------------------+--------+
| CoffeeSingleRequestParamBench | 4.81x |
| DVKSingleRequestParamBench | 2.37x |
| HoaSingleRequestParamBench | 4.59x |
| IBSingleRequestParamBench | 13.12x |
| MezonSingleRequestParamBench | 10.42x |
| MiladSingleRequestParamBench | 2.93x |
| PeceeSingleRequestParamBench | 6.40x |
| PowerSingleRequestParamBench | 2.84x |
| SteampixelSingleRequestParamBench | 26.93x |
| ToroSingleRequestParamBench | 1.00x |
+-----------------------------------+--------+

The second case + static routes

+----------------------------+------------+
| benchmark | diff |
+----------------------------+------------+
| CoffeeReactStaticBench | 771.02x |
| DVKReactStaticBench | 510.43x |
| HoaReactStaticBench | 161.55x |
| IBReactStaticBench | 1,166.30x |
| MezonReactStaticBench | 1.00x |
| MiladReactStaticBench | 823.27x |
| PeceeReactStaticBench | 1,065.17x |
| PowerReactStaticBench | 793.37x |
| SteampixelReactStaticBench | 10,868.16x |
| ToroReactStaticBench | 16.31x |
+----------------------------+------------+

The second case + non-static routes

+---------------------------+---------+
| benchmark | diff |
+---------------------------+---------+
| DVKReactParamBench | 11.91x |
| HoaReactParamBench | 5.34x |
| IBReactParamBench | 35.23x |
| MezonReactParamBench | 1.00x |
| MiladReactParamBench | 19.73x |
| PeceeReactParamBench | 41.28x |
| PowerReactParamBench | 14.54x |
| SteampixelReactParamBench | 212.60x |
| ToroReactParamBench | 7.54x |
+---------------------------+---------+

As you can see in some cases Toro is the fastest router, in some cases it is not, but still shows good results.

What’s next?

More articles can be found in my Twitter

What is mezon/router?

mezon/router now is:

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 )

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store