<?php require 'SimpleBench/Task.php'; require 'SimpleBench/Utils.php'; require 'SimpleBench/ComparisonMatrix.php'; require 'SimpleBench/SystemInfo/Darwin.php'; require 'SimpleBench/MatrixWriter/Writer.php'; require 'SimpleBench/MatrixWriter/JsonWriter.php'; require 'SimpleBench/MatrixPrinter/EzcGraph.php'; require 'SimpleBench/MatrixPrinter/Console.php'; require 'SimpleBench.php'; // requirement from symfon require '../src/Pux/PatternCompiler.php'; use Pux\Mux; $mux = Pux\Mux::__set_state(array('id' => NULL, 'routes' => array(0 => array(0 => false, 1 => '/hello', 2 => array(0 => 'HelloController', 1 => 'helloAction'), 3 => array())), 'routesById' => array(), 'staticRoutes' => array(), 'submux' => array(), 'expand' => true)); /* version */ $bench = new SimpleBench(); $bench->setN(10000); $bench->iterate('match', function () use($mux) { $route = $mux->match('/hello'); }); $bench->iterate('dispatch', function () use($mux) { $route = $mux->dispatch('/hello'); }); $bench->iterate('__set_state', function () { $mux = Pux\Mux::__set_state(array('id' => NULL, 'routes' => array(0 => array(0 => false, 1 => '/hello', 2 => array(0 => 'HelloController', 1 => 'helloAction'), 3 => array())), 'routesById' => array(), 'staticRoutes' => array(), 'submux' => array(), 'expand' => true)); /* version */ }); $result = $bench->compare(); echo $result->output('console');
require 'SimpleBench/MatrixWriter/JsonWriter.php'; require 'SimpleBench/MatrixPrinter/EzcGraph.php'; require 'SimpleBench/MatrixPrinter/Console.php'; require 'SimpleBench/SystemInfo/Darwin.php'; require 'SimpleBench.php'; // requirement from symfon require 'symfony/vendor/autoload.php'; require 'pux/PatternCompiler.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; use Pux\Mux; $bench = new SimpleBench(); $bench->setN(5000); $mux = new Mux(); $mux->add('/product/:id', ['ProductController', 'index']); $bench->iterate('pux extension (dispatch)', function () use($mux) { $route = $mux->dispatch('/product/23'); }); $routes = new RouteCollection(); $routes->add('product', new Route('/product/{id}', array('controller' => 'foo', 'action' => 'bar'))); $bench->iterate('symfony/routing (dispatch)', function () use($routes) { $context = new RequestContext(); // this is optional and can be done without a Request instance $context->fromRequest(Request::createFromGlobals()); $matcher = new UrlMatcher($routes, $context); $route = $matcher->match('/product/23'); }); $result = $bench->compare();
} require '../vendor/pear/Universal/ClassLoader/BasePathClassLoader.php'; $loader = new \Universal\ClassLoader\BasePathClassLoader(array('../src', '../vendor/pear', '/opt/local/lib/php')); $loader->useIncludePath(true); $loader->register(); echo "init router\n"; $router = new Roller\Router(); $router->add('/', function () { return 'Hello World, please request /=/test for RESTful resource handler demo.'; }); foreach (range(1, 1000) as $i) { $router->add('/foo' . $i, function () { return 'bar'; }); } $router->routes->compile(); // var_dump( $router->routes->routes ); echo "dispatching\n"; $b = new SimpleBench(); $b->setN(10); $b->iterate('roller_ext', 'roller_ext', function () use($router) { $r = roller_dispatch($router->routes->routes, '/foo1000'); }); $router->enableExtension = false; $b->iterate('roller', 'roller', function () use($router) { $r = $router->dispatch('/foo1000'); }); // var_dump( $r , $regs ); // var_dump( hello_array_value( array( 'foo' => 'what' ) , 'foo' ) ); $result = $b->compare(); echo $result->output('Console');