Completed
Push — master ( d41a26...1c5167 )
by Gabriel
04:02
created

GenerationBench::benchAssembleStaticNip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 1
1
<?php
2
3
use Nip\Router\Route\Route;
4
use Nip\Router\RouteFactory;
5
use Nip\Router\Router;
6
use Nip\Router\Tests\Fixtures\Application\Library\Router\Route\StandardRoute;
7
8
/**
9
 * Class GeneratingBench
10
 * @Iterations(5)
11
 * @Revs(100)
12
 * @BeforeMethods({"init"})
13
 */
14
class GenerationBench
15
{
16
    /**
17
     * @var Router
18
     */
19
    protected $router;
20
21
    public function benchAssembleStaticNip()
22
    {
23
        $this->router->assemble(
24
            'index.999',
25
            ['controller' => 'posts', 'action' => 'create', 'title' => 'test']
26
        );
27
    }
28
29
    public function benchAssembleStandardNip()
30
    {
31
        $this->router->assemble(
32
            'index.standard999',
33
            ['controller' => 'posts', 'action' => 'create', 'title' => 'test']
34
        );
35
    }
36
37
    public function benchAssembleStaticSymfony()
38
    {
39
        $this->router->generate(
40
            'index.999',
41
            ['controller' => 'posts', 'action' => 'create', 'title' => 'test']
42
        );
43
    }
44
45
    public function benchAssembleDynamicSymfony()
46
    {
47
        $this->router->generate(
48
            'index.standard999',
49
            ['controller' => 'posts', 'action' => 'create', 'title' => 'test']
50
        );
51
    }
52
53
    public function init()
54
    {
55
        $this->router = new Router();
56
        $collection = $this->router->getRoutes();
57
58
        for ($i = 0; $i < 1000; ++$i) {
59
            RouteFactory::generateLiteralRoute(
60
                $collection,
61
                "index." . $i,
62
                Route::class,
63
                "",
64
                "/index" . $i);
65
66
            RouteFactory::generateStandardRoute(
67
                $collection,
68
                "index.standard" . $i,
69
                StandardRoute::class,
70
                "/" . $i);
71
        }
72
    }
73
}
74