New benchmark: Mezon Router VS Phroute

Hello all! The time I shall compare Phroute with Mezon Router.

As usual we have two cases:

  1. http server accepts request, launches php script, which handles this request, and then all script data uploads 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.

First case

// static routes
for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
$router = \Mezon\Benchmark\RouteGenerator::generatePhrouteStaticRoutes(1000);
$router->dispatch('GET', parse_url('/static/' . rand(0, 1000 - 1), PHP_URL_PATH));
}
// non-static routes
for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
$router = \Mezon\Benchmark\RouteGenerator::generatePhrouteNonStaticRoutes(1000);
$router->dispatch('GET', parse_url('/param/' . rand(0, 1000 - 1) . '/1', PHP_URL_PATH));
}

Second case

// static routes
$router = \Mezon\Benchmark\RouteGenerator::generatePhrouteStaticRoutes(1000);
$startTime = microtime(true);
for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
$router->dispatch('GET', parse_url('/static/' . rand(0, 1000 - 1), PHP_URL_PATH));
}
return microtime(true) - $startTime;
// non-static routes
$router = \Mezon\Benchmark\RouteGenerator::generatePhrouteNonStaticRoutes(1000);
$startTime = microtime(true);
for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
$router->dispatch('GET', parse_url('/param/' . rand(0, 1000 - 1) . '/1', PHP_URL_PATH));
}
return microtime(true) - $startTime;

Results

As you can see Mezon router is almost in all cases is faster then Phroute.

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

DSC WOW Workshop Experience

End to End MLOps on Azure

What’s wrong with Medium notification?

Apache Cassandra, Part 5: Data Modelling with Examples

Comparing Graph Databases

From Pandas to Hello Panda to Food Panda!

Sucking & Blowing

Apache Cassandra Cluster on Google Cloud

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

Startup journey from Elastic Beanstalk to Kubernetes containers

General flow

Retrieve random documents from Meilisearch

How Do You Create Own Wireguard Vpn On AWS EC2 with Tailscale

Innodb_buffer_pool_size

innodb_buffer_pool_size tuning