An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
June 23, 2021 09:42 am GMT
Original Link: https://dev.to/alexdodonov/new-benchmark-mezon-router-vs-power-router-5h4g
New benchmark: Mezon Router VS Power Router
Hi all! Today we have one more benchmark.
As usual we have two cases:
- 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;
- 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$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/0';$router = RouteGenerator::generatePowerStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/99';$router = RouteGenerator::generatePowerStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/199';$router = RouteGenerator::generatePowerStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());// and so on up to /static/999 route
// non static routes$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/0/1/';$router = RouteGenerator::generatePowerNonStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/99/1/';$router = RouteGenerator::generatePowerNonStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/199/1/';$router = RouteGenerator::generatePowerNonStaticRoutes(1000);$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());// and so on up to /param/999/1 route
The second case
// static routes$router = RouteGenerator::generatePowerStaticRoutes(1000);$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/0';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/99';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/static/199';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());// and so on up to /static/999 route
// non static routes$router = RouteGenerator::generatePowerNonStaticRoutes(1000);$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/0/1/';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/99/1/';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());$_SERVER['REQUEST_METHOD'] = 'GET';$_SERVER['REQUEST_URI'] = '/param/199/1/';$request = ServerRequestFactory::fromGlobals();$router->start($request, new Response());// and so on up to /param/999/1 route
OK What do we have?
The first case + static routes
+------------------------------------+-------------+-----+------+-----+-------------+---------------+---------------+---------------+---------------+--------------+--------+---------+| benchmark | subject | set | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |+------------------------------------+-------------+-----+------+-----+-------------+---------------+---------------+---------------+---------------+--------------+--------+---------+| CoffeeSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 2,936,232b | 41,057.300s | 84,148.370s | 47,592.655s | 249,780.200s | 74,221.744s | 88.20% | 48.66x || DVKSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 3,392,992b | 25,714.700s | 26,682.450s | 26,362.514s | 28,618.500s | 819.301s | 3.07% | 15.43x || HoaSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 3,847,864b | 44,176.400s | 47,097.030s | 45,321.883s | 63,058.400s | 5,365.782s | 11.39% | 27.23x || IBSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 3,471,624b | 126,073.700s | 130,365.100s | 128,767.356s | 143,720.600s | 4,833.922s | 3.71% | 75.39x || MezonSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 2,287,376b | 9,073.900s | 9,357.890s | 9,297.606s | 9,896.300s | 236.985s | 2.53% | 5.41x || MiladSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 33,649,608b | 29,915.300s | 30,749.180s | 30,291.549s | 33,174.000s | 977.528s | 3.18% | 17.78x || PeceeSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 7,085,072b | 36,595.500s | 37,232.050s | 37,031.929s | 38,438.600s | 554.518s | 1.49% | 21.53x || PowerSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 3,862,216b | 19,049.200s | 20,140.870s | 19,808.905s | 21,000.000s | 643.417s | 3.19% | 11.65x || SteampixelSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 2,566,392b | 207,734.200s | 210,574.660s | 210,950.748s | 212,526.200s | 1,389.866s | 0.66% | 121.77x || ToroSingleRequestStaticBench | benchStatic | 0 | 10 | 10 | 1,745,216b | 1,476.200s | 1,729.290s | 1,583.368s | 2,666.700s | 346.981s | 20.06% | 1.00x |+------------------------------------+-------------+-----+------+-----+-------------+---------------+---------------+---------------+---------------+--------------+--------+---------+
The first case + non-static routes
+-----------------------------------+------------+-----+------+-----+--------------+---------------+---------------+---------------+---------------+---------------+--------+--------+| benchmark | subject | set | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |+-----------------------------------+------------+-----+------+-----+--------------+---------------+---------------+---------------+---------------+---------------+--------+--------+| CoffeeSingleRequestParamBench | benchParam | 0 | 10 | 10 | 3,903,272b | 53,137.000s | 53,669.140s | 53,434.041s | 54,304.600s | 398.649s | 0.74% | 4.85x || DVKSingleRequestParamBench | benchParam | 0 | 10 | 10 | 3,385,376b | 29,081.100s | 30,110.190s | 29,726.930s | 31,490.000s | 755.289s | 2.51% | 2.72x || HoaSingleRequestParamBench | benchParam | 0 | 10 | 10 | 4,165,464b | 45,786.400s | 46,825.120s | 46,833.564s | 47,952.800s | 583.437s | 1.25% | 4.23x || IBSingleRequestParamBench | benchParam | 0 | 10 | 10 | 3,592,344b | 145,910.100s | 147,746.210s | 147,306.262s | 150,106.800s | 1,239.601s | 0.84% | 13.36x || MezonSingleRequestParamBench | benchParam | 0 | 10 | 10 | 139,508,728b | 124,171.600s | 126,109.060s | 125,425.730s | 130,917.500s | 1,915.883s | 1.52% | 11.41x || MiladSingleRequestParamBench | benchParam | 0 | 10 | 10 | 34,508,144b | 35,645.000s | 36,320.080s | 36,141.269s | 37,270.600s | 527.261s | 1.45% | 3.28x || PeceeSingleRequestParamBench | benchParam | 0 | 10 | 10 | 6,669,256b | 75,824.900s | 84,586.110s | 78,820.332s | 109,839.700s | 10,653.230s | 12.59% | 7.65x || PowerSingleRequestParamBench | benchParam | 0 | 10 | 10 | 3,862,216b | 20,937.700s | 28,584.620s | 24,077.098s | 40,265.800s | 7,123.452s | 24.92% | 2.59x || SteampixelSingleRequestParamBench | benchParam | 0 | 10 | 10 | 2,666,344b | 235,446.700s | 348,940.010s | 297,900.248s | 691,357.600s | 128,878.867s | 36.93% | 31.56x || ToroSingleRequestParamBench | benchParam | 0 | 10 | 10 | 1,866,176b | 9,774.800s | 11,056.990s | 10,512.857s | 12,358.000s | 835.968s | 7.56% | 1.00x |+-----------------------------------+------------+-----+------+-----+--------------+---------------+---------------+---------------+---------------+---------------+--------+--------+
The second case + static routes
+----------------------------+-------------+-----+------+-----+------------+---------------+---------------+---------------+-----------------+---------------+--------+------------+| benchmark | subject | set | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |+----------------------------+-------------+-----+------+-----+------------+---------------+---------------+---------------+-----------------+---------------+--------+------------+| CoffeeReactStaticBench | benchStatic | 0 | 10 | 10 | 2,409,400b | 7,916.900s | 8,434.210s | 8,309.219s | 9,401.900s | 425.183s | 5.04% | 410.30x || DVKReactStaticBench | benchStatic | 0 | 100 | 10 | 2,652,296b | 10,289.710s | 10,796.560s | 10,512.391s | 13,365.110s | 864.430s | 8.01% | 525.23x || HoaReactStaticBench | benchStatic | 0 | 100 | 10 | 2,893,936b | 3,576.030s | 3,622.525s | 3,606.191s | 3,731.710s | 43.214s | 1.19% | 176.23x || IBReactStaticBench | benchStatic | 0 | 10 | 10 | 3,034,880b | 25,829.300s | 26,309.220s | 26,380.221s | 26,774.000s | 303.353s | 1.15% | 1,279.88x || MezonReactStaticBench | benchStatic | 0 | 100 | 10 | 1,908,208b | 18.630s | 20.556s | 18.987s | 25.150s | 2.436s | 11.85% | 1.00x || MiladReactStaticBench | benchStatic | 0 | 10 | 10 | 5,275,192b | 15,524.100s | 16,269.690s | 16,402.613s | 17,264.100s | 511.121s | 3.14% | 791.48x || PeceeReactStaticBench | benchStatic | 0 | 10 | 10 | 4,243,936b | 19,101.900s | 20,167.700s | 19,701.218s | 22,467.300s | 1,012.717s | 5.02% | 981.11x || PowerReactStaticBench | benchStatic | 0 | 10 | 10 | 3,029,632b | 15,172.800s | 15,635.430s | 15,559.212s | 16,680.100s | 397.706s | 2.54% | 760.63x || SteampixelReactStaticBench | benchStatic | 0 | 10 | 10 | 2,605,560b | 239,026.100s | 346,973.110s | 250,424.922s | 1,209,825.800s | 288,217.061s | 83.07% | 16,879.41x || ToroReactStaticBench | benchStatic | 0 | 10 | 10 | 1,734,616b | 351.800s | 382.130s | 364.151s | 480.600s | 39.107s | 10.23% | 18.59x |+----------------------------+-------------+-----+------+-----+------------+---------------+---------------+---------------+-----------------+---------------+--------+------------+
The second case + non-static routes
+---------------------------+------------+-----+------+-----+------------+---------------+---------------+---------------+---------------+--------------+--------+---------+| benchmark | subject | set | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |+---------------------------+------------+-----+------+-----+------------+---------------+---------------+---------------+---------------+--------------+--------+---------+| CoffeeReactParamBench | benchParam | 0 | 10 | 10 | 2,409,368b | 8,548.600s | 9,257.830s | 8,950.739s | 10,758.200s | 640.445s | 6.92% | 6.19x || DVKReactParamBench | benchParam | 0 | 100 | 10 | 2,656,688b | 14,344.960s | 18,446.126s | 16,842.581s | 31,828.310s | 4,840.866s | 26.24% | 12.34x || HoaReactParamBench | benchParam | 0 | 100 | 10 | 3,360,824b | 3,862.030s | 4,972.977s | 4,750.023s | 6,237.760s | 730.301s | 14.69% | 3.33x || IBReactParamBench | benchParam | 0 | 10 | 10 | 3,157,360b | 43,412.000s | 59,080.640s | 54,258.725s | 95,701.400s | 14,431.920s | 24.43% | 39.52x || MezonReactParamBench | benchParam | 0 | 100 | 10 | 3,129,488b | 1,178.510s | 1,494.984s | 1,341.991s | 2,096.520s | 283.938s | 18.99% | 1.00x || MiladReactParamBench | benchParam | 0 | 10 | 10 | 5,402,688b | 22,573.900s | 28,562.900s | 24,596.006s | 49,765.900s | 8,124.021s | 28.44% | 19.11x || PeceeReactParamBench | benchParam | 0 | 10 | 10 | 4,625,032b | 47,438.500s | 53,523.160s | 49,062.308s | 71,146.100s | 8,897.750s | 16.62% | 35.80x || PowerReactParamBench | benchParam | 0 | 10 | 10 | 3,029,632b | 16,629.600s | 17,320.220s | 17,040.916s | 18,338.400s | 523.710s | 3.02% | 11.59x || SteampixelReactParamBench | benchParam | 0 | 10 | 10 | 2,664,712b | 250,206.800s | 270,897.140s | 256,660.290s | 299,426.700s | 16,652.239s | 6.15% | 181.20x || ToroReactParamBench | benchParam | 0 | 10 | 10 | 1,785,112b | 8,329.400s | 8,866.510s | 8,599.075s | 9,795.400s | 478.527s | 5.40% | 5.93x |+---------------------------+------------+-----+------+-----+------------+---------------+---------------+---------------+---------------+--------------+--------+---------+
As you can see in some cases Power Router 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:
- 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 )
Original Link: https://dev.to/alexdodonov/new-benchmark-mezon-router-vs-power-router-5h4g
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To