Passed
Push — master ( 71b494...4cbbee )
by Anatoly
01:42
created

AuraBench   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A benchAuraMatch() 0 17 2
1
<?php
2
3
namespace Sunrise\Http\Router\Benchs;
4
5
use Aura\Router\RouterContainer;
0 ignored issues
show
Bug introduced by
The type Aura\Router\RouterContainer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Sunrise\Http\ServerRequest\ServerRequestFactory;
7
8
/**
9
 * @BeforeMethods({"init"})
10
 */
11
class AuraBench
12
{
13
	protected $maxRoutes = 1000;
14
	protected $request;
15
16
	public function init()
17
	{
18
		$uri = \sprintf('/route/%d', $this->maxRoutes);
19
20
		$this->request = (new ServerRequestFactory)
21
		->createServerRequest('GET', $uri);
22
	}
23
24
	/**
25
	 * @Warmup(1)
26
	 * @Revs(10)
27
	 * @Iterations(100)
28
	 */
29
	public function benchAuraMatch()
30
	{
31
		$routerContainer = new RouterContainer();
32
33
		$map = $routerContainer->getMap();
34
35
		for ($i = 1; $i <= $this->maxRoutes; $i++)
36
		{
37
			$id = \sprintf('route:%d', $i);
38
			$path = \sprintf('/route/%d', $i);
39
			$action = function() {};
40
41
			$map->get($id, $path, $action);
42
		}
43
44
		$matcher = $routerContainer->getMatcher();
45
		$matcher->match($this->request);
46
	}
47
}
48