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

// static routes
$router = RouteGenerator::generateJoomlaStaticRoutes(1000);
$controller = $router->getController('/static/0');
$controller->execute();
$router = RouteGenerator::generateJoomlaStaticRoutes(1000);
$controller = $router->getController('/static/99');
$controller->execute();
$router = RouteGenerator::generateJoomlaStaticRoutes(1000);
$controller = $router->getController('/static/199');
$controller->execute();
// and so on up to /static/999 route
// non static routes
$router = RouteGenerator::generateJoomlaNonStaticRoutes(1000);
$controller = $router->getController('/param/1/0');
$controller->execute();
$router = RouteGenerator::generateJoomlaNonStaticRoutes(1000);
$controller = $router->getController('/param/1/99');
$controller->execute();
$router = RouteGenerator::generateJoomlaNonStaticRoutes(1000);
$controller = $router->getController('/param/1/199');
$controller->execute();
// and so on up to /param/999/1 route

The second case

// static routes
$router = RouteGenerator::generateJoomlaStaticRoutes(1000);
$controller = $router->getController('/static/0');
$controller->execute();
$controller = $router->getController('/static/99');
$controller->execute();
$controller = $router->getController('/static/199');
$controller->execute();
// and so on up to /static/999 route
// non static routes
$router = RouteGenerator::generateJoomlaNonStaticRoutes(1000);
$controller = $router->getController('/param/1/0');
$controller->execute();
$controller = $router->getController('/param/1/99');
$controller->execute();
$controller = $router->getController('/param/1/199');
$controller->execute();
// and so on up to /param/1/999 route

OK What do we have?

The first case + static routes

+------------------------------------+---------+
| benchmark | diff |
+------------------------------------+---------+
| CoffeeSingleRequestStaticBench | 30.05x |
| DVKSingleRequestStaticBench | 18.41x |
| HoaSingleRequestStaticBench | 40.34x |
| IBSingleRequestStaticBench | 82.37x |
| JoomlaSingleRequestStaticBench | 18.57x |
| MezonSingleRequestStaticBench | 6.05x |
| MiladSingleRequestStaticBench | 18.73x |
| PeceeSingleRequestStaticBench | 24.78x |
| PowerSingleRequestStaticBench | 13.77x |
| SteampixelSingleRequestStaticBench | 135.12x |
| ToroSingleRequestStaticBench | 1.00x |
| ZaphpaSingleRequestStaticBench | 21.83x |
+------------------------------------+---------+

The first case + non-static routes

+-----------------------------------+--------+
| benchmark | diff |
+-----------------------------------+--------+
| CoffeeSingleRequestParamBench | 5.38x |
| DVKSingleRequestParamBench | 2.78x |
| HoaSingleRequestParamBench | 4.20x |
| IBSingleRequestParamBench | 13.25x |
| JoomlaSingleRequestParamBench | 3.32x |
| MezonSingleRequestParamBench | 11.22x |
| MiladSingleRequestParamBench | 3.38x |
| PeceeSingleRequestParamBench | 7.25x |
| PowerSingleRequestParamBench | 2.28x |
| SteampixelSingleRequestParamBench | 22.32x |
| ToroSingleRequestParamBench | 1.00x |
| ZaphpaSingleRequestParamBench | 4.66x |
+-----------------------------------+--------+

The second case + static routes

+----------------------------+-----------+
| benchmark | diff |
+----------------------------+-----------+
| CoffeeReactStaticBench | 277.63x |
| DVKReactStaticBench | 460.24x |
| HoaReactStaticBench | 146.80x |
| IBReactStaticBench | 1,362.26x |
| JoomlaReactStaticBench | 186.80x |
| MezonReactStaticBench | 1.00x |
| MiladReactStaticBench | 621.50x |
| PeceeReactStaticBench | 760.66x |
| PowerReactStaticBench | 518.41x |
| SteampixelReactStaticBench | 8,955.72x |
| ToroReactStaticBench | 19.12x |
| ZaphpaReactStaticBench | 536.46x |
+----------------------------+-----------+

The second case + non-static routes

+---------------------------+---------+
| benchmark | diff |
+---------------------------+---------+
| CoffeeReactParamBench | 15.15x |
| DVKReactParamBench | 11.86x |
| HoaReactParamBench | 4.59x |
| IBReactParamBench | 29.10x |
| JoomlaReactParamBench | 4.44x |
| MezonReactParamBench | 1.00x |
| MiladReactParamBench | 20.14x |
| PeceeReactParamBench | 41.78x |
| PowerReactParamBench | 13.73x |
| SteampixelReactParamBench | 243.13x |
| ToroReactParamBench | 6.94x |
| ZaphpaReactParamBench | 19.28x |
+---------------------------+---------+

As you can see almost in all cases Mezon Router is faster that Joomla router.

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 )

--

--

--

php developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deprecation Warning With GraphQL + NestJS Versionless API

React Hooks Tutorial for Beginners

What is objects in javascript? How are they represented?

Angular 8 — What is Angular and Why to use it

Every Beginner JavaScript Developer Should be Known About This Methode

Integrating D3 with Tableau

Is React a Good Choice for Your IoT Project?

idomoo ❤️ Discord

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
Dodonov Alexey

Dodonov Alexey

php developer

More from Medium

Top 15 Achievements of CodeRiders Software Company in 2021

CodeRiders is a recognized software company among the international IT industry

The basics of creating a website using Hacklang+HHVM

GSoC 2015 — Moorsp plugin for Moodle — Wrap Up

Building a “People who bought this item but also bought” recommendation engine.

Rough process flow of how the recommended products are generated.