PHP Classes

File: tests/fast-route.php

Recommend this page to a friend!
  Classes of Alexey Dodonov   Mezon Router Benchmark   tests/fast-route.php   Download  
File: tests/fast-route.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Mezon Router Benchmark
Measure the performance of PHP framework routers
Author: By
Last change:
Date: 1 year ago
Size: 1,103 bytes
 

Contents

Class file image Download
<?php
$benchmark
->registerTest(function () {
   
$startTime = microtime(true);
    for (
$i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
       
$dispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
           
$r->addRoute('GET', '/static', function () {
                return
'static';
            });
        });
       
$routeInfo = $dispatcher->dispatch('GET', '/static');
       
$routeInfo[1]();
    }
    return
microtime(true) - $startTime;
},
"[fast-route] Resolving static routes %f per second\r\n");

$benchmark->registerTest(function () {
   
$startTime = microtime(true);
    for (
$i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
       
$dispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
           
$r->addRoute('GET', '/{id:\d+}', function () {
                return
'param';
            });
        });
       
$routeInfo = $dispatcher->dispatch('GET', '/1');
       
$routeInfo[1]();
    }
    return
microtime(true) - $startTime;
},
"[fast-route] Resolving param. routes %f per second\r\n");