PHP Classes

File: tests/aura/single-request-1000.php

Recommend this page to a friend!
  Classes of Alexey Dodonov   Mezon Router Benchmark   tests/aura/single-request-1000.php   Download  
File: tests/aura/single-request-1000.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: 2 years ago
Size: 1,374 bytes
 

Contents

Class file image Download
<?php
$benchmark
->registerTest(
    function () {
       
$_SERVER['REQUEST_METHOD'] = 'GET';
       
$startTime = microtime(true);
        for (
$i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
           
$_SERVER['REQUEST_URI'] = '/static/' . rand(0, 1000 - 1);

           
$request = \Zend\Diactoros\ServerRequestFactory::fromGlobals($_SERVER);

           
$router = \Mezon\Benchmark\RouteGenerator::generateAuraStaticRoutes(1000);

           
$route = $router->match($request);
           
$route->handler($request);
        }
        return
microtime(true) - $startTime;
    },
   
"[aura/single-request/1000 routes] Resolving static routes %f per second\r\n");

$benchmark->registerTest(
    function () {
       
$_SERVER['REQUEST_METHOD'] = 'GET';
       
$startTime = microtime(true);
        for (
$i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {
           
$_SERVER['REQUEST_URI'] = '/param/' . rand(0, 1000 - 1) . '/1';

           
$request = \Zend\Diactoros\ServerRequestFactory::fromGlobals($_SERVER);

           
$router = \Mezon\Benchmark\RouteGenerator::generateAuraNonStaticRoutes(1000);

           
$route = $router->match($request);
           
$route->handler($request);
        }
        return
microtime(true) - $startTime;
    },
   
"[aura/single-request/1000 routes] Resolving param. routes %f per second\r\n");