/**
 * Sets up Aura v2 tests
 *
 * https://github.com/auraphp/Aura.Router
 */
function setupAura2(Benchmark $benchmark, $routes, $args)
{
    $argString = implode('/', array_map(function ($i) {
        return "{arg{$i}}";
    }, range(1, $args)));
    $lastStr = '';
    $router = new \Aura\Router\Router(new \Aura\Router\RouteCollection(new \Aura\Router\RouteFactory()), new \Aura\Router\Generator());
    for ($i = 0, $str = 'a'; $i < $routes; $i++, $str++) {
        list($pre, $post) = getRandomParts();
        $str = '/' . $pre . '/' . $argString . '/' . $post;
        if (0 === $i) {
            $firstStr = str_replace(array('{', '}'), '', $str);
        }
        $lastStr = str_replace(array('{', '}'), '', $str);
        $router->add($str, $str)->addValues(array('controller' => 'handler' . $i));
    }
    $benchmark->register(sprintf('Aura v2 - last route (%s routes)', $routes), function () use($router, $lastStr) {
        $route = $router->match($lastStr, $_SERVER);
    });
    $benchmark->register(sprintf('Aura v2 - unknown route (%s routes)', $routes), function () use($router) {
        $route = $router->match('/not-even-real', $_SERVER);
    });
}
/**
 * Sets up CogRoute tests
 */
function setupCogRoute(Benchmark $benchmark, $routes, $args)
{
    $argString = implode('/', array_map(function ($i) {
        return "{arg{$i}}";
    }, range(1, $args)));
    $str = $firstStr = $lastStr = '';
    $router = new \Cog\Router\Core();
    for ($i = 0; $i < $routes; $i++) {
        list($pre, $post) = getRandomParts();
        $str = '/' . $pre . '/' . $argString . '/' . $post;
        if (0 === $i) {
            $firstStr = str_replace(array('{', '}'), '', $str);
        }
        $lastStr = str_replace(array('{', '}'), '', $str);
        $router->add(null, $str, 'handler' . $i);
    }
    $benchmark->register(sprintf('CogRoute - first route', $routes), function () use($router, $firstStr) {
        $route = $router->find($firstStr);
    });
}