Completed
Push — master ( aa06ba...5b92e1 )
by Jaap
10:02 queued 11s
created

TypeResolverWithContextBench   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 6 1
A benchResolveCompoundArrayWithDefinedTypes() 0 4 1
A benchArrayOfClass() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace benchmark;
6
7
use phpDocumentor\Reflection\TypeResolver;
8
use phpDocumentor\Reflection\Types\Context;
9
use phpDocumentor\Reflection\Types\ContextFactory;
10
11
/**
12
 * @BeforeMethods({"setup"})
13
 */
14
final class TypeResolverWithContextBench
15
{
16
    /**
17
     * @var Context
18
     */
19
    private $context;
20
21
    /**
22
     * @var TypeResolver
23
     */
24
    private $typeResolver;
25
26
    public function setup()
27
    {
28
        $factory = new ContextFactory();
29
        $this->context = $factory->createForNamespace('mpdf', file_get_contents(__DIR__ . '/Assets/mpdf.php'));
30
        $this->typeResolver = new TypeResolver();
31
    }
32
33
    /**
34
     * @Warmup(2)
35
     * @Executor(
36
     *     "blackfire",
37
     *     assertions={
38
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
39
     *      "main.wall_time < 1ms"
40
     *      }
41
     * )
42
     */
43
    public function benchResolveCompoundArrayWithDefinedTypes() : void
44
    {
45
        $this->typeResolver->resolve('array<int, string>|array<int, int>', $this->context);
46
    }
47
48
    /**
49
     * @Warmup(2)
50
     * @Executor(
51
     *     "blackfire",
52
     *     assertions={
53
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
54
     *      "main.wall_time < 1ms"
55
     *      }
56
     * )
57
     */
58
    public function benchArrayOfClass() : void
59
    {
60
        $this->typeResolver->resolve('Conversion[]', $this->context);
61
    }
62
}
63