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

MatchingBench::init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 20
loc 20
rs 9.6
c 0
b 0
f 0
1
<?php
2
3
use Nip\Request;
4
use Nip\Router\Route\Route;
5
use Nip\Router\RouteFactory;
6
use Nip\Router\Router;
7
use Nip\Router\Tests\Fixtures\Application\Library\Router\Route\StandardRoute;
8
9
/**
10
 * Class MatchingBench
11
 * @Iterations(5)
12
 * @Revs(100)
13
 * @BeforeMethods({"init"})
14
 */
15
class MatchingBench
16
{
17
    /**
18
     * @var Router
19
     */
20
    protected $router;
21
22
    public function benchStaticRoutesNip()
23
    {
24
        $request = Request::create('/index999');
25
        $this->router->route($request);
0 ignored issues
show
Deprecated Code introduced by
The function Nip\Router\Router::route() has been deprecated: Use matchRequest($request) ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

25
        /** @scrutinizer ignore-deprecated */ $this->router->route($request);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
26
    }
27
28
    public function benchDynamicRoutesNip()
29
    {
30
        $request = Request::create('/999/posts/create');
31
        $this->router->route($request);
0 ignored issues
show
Deprecated Code introduced by
The function Nip\Router\Router::route() has been deprecated: Use matchRequest($request) ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
        /** @scrutinizer ignore-deprecated */ $this->router->route($request);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
32
    }
33
34
    public function benchStaticRoutesSymfony()
35
    {
36
        $request = Request::create('/index999');
37
        $this->router->matchRequest($request);
38
    }
39
40
    public function benchDynamicRoutesSymfony()
41
    {
42
        $request = Request::create('/999/posts/create');
43
        $this->router->matchRequest($request);
44
    }
45
46
    public function init()
47
    {
48
        $this->router = new Router();
49
        $collection = $this->router->getRoutes();
50
51
        for ($i = 0; $i < 1000; ++$i) {
52
            RouteFactory::generateLiteralRoute(
53
                $collection,
54
                "index." . $i,
55
                Route::class,
56
                "",
57
                "/index" . $i);
58
59
            RouteFactory::generateStandardRoute(
60
                $collection,
61
                "index.standard" . $i,
62
                StandardRoute::class,
63
                "/".$i);
64
        }
65
    }
66
}
67