Monday 13 April 2020

Benchmark between Symfony HttpFoundation and Nette Http RequestFactory

<?php

require_once 'vendor/autoload.php';
$s = 0;
$n = 0;

$bench = new Ubench;
for ($i=0; $i < 10000; $i++) {
   
$bench->start();
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$bench->end();

// Get elapsed time and memory
$s += $bench->getTime(true); // elapsed microtime in float

$bench->start();
$request = new Nette\Http\RequestFactory;
$request->fromGlobals();
$bench->end();

$n += $bench->getTime(true); // elapsed microtime in float

}

echo "<br>Symfony average request: " . $s/10000 . '<br>';
echo "Nette average request: " . $n/10000;


Result: Average request Time

Welcome to the framework
Symfony average request : 0.0016007466554642
Nette average request: 0.0020953632354736

        "symfony/http-foundation":"5.0.7",

symfony/http-foundation is the clear winner


        "symfony/http-foundation":"5.0.7",

        "nette/http""^3.0"

No comments:

Post a Comment