Passed
Push — phpbench ( ffc4ab )
by Michael
02:36
created

DocParsePerformanceBench::benchClassParsing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Performance\Annotations;
6
7
use Doctrine\Annotations\DocParser;
8
use Doctrine\Tests\Annotations\Fixtures\Annotation\Route;
9
use Doctrine\Tests\Annotations\Fixtures\Annotation\Template;
10
11
/**
12
 * @BeforeMethods({"initializeMethod", "initialize"})
13
 */
14
final class DocParsePerformanceBench
15
{
16
    use MethodInitializer;
17
18
    private const IMPORTS = [
19
        'ignorephpdoc'     => 'Annotations\Annotation\IgnorePhpDoc',
20
        'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation',
21
        'route'            => Route::class,
22
        'template'         => Template::class,
23
        '__NAMESPACE__'    => 'Doctrine\Tests\Annotations\Fixtures',
24
    ];
25
26
    private const IGNORED = [
27
        'access', 'author', 'copyright', 'deprecated', 'example', 'ignore',
28
        'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package',
29
        'subpackage', 'name', 'global', 'param', 'return', 'staticvar',
30
        'static', 'var', 'throws', 'inheritdoc',
31
    ];
32
33
    /** @var DocParser */
34
    private $parser;
35
36
    public function initialize() : void
37
    {
38
        $this->parser = new DocParser();
39
40
        $this->parser->setImports(self::IMPORTS);
41
        $this->parser->setIgnoredAnnotationNames(array_fill_keys(self::IGNORED, true));
42
        $this->parser->setIgnoreNotImportedAnnotations(true);
43
    }
44
45
    /**
46
     * @Revs(200)
47
     * @Iterations(5)
48
     */
49
    public function benchMethodParsing() : void
50
    {
51
        $this->parser->parse($this->methodDocBlock);
52
    }
53
54
    /**
55
     * @Revs(200)
56
     * @Iterations(5)
57
     */
58
    public function benchClassParsing() : void
59
    {
60
        $this->parser->parse($this->classDocBlock);
61
    }
62
}
63