File: DocParserPerformanceBench.php

package info (click to toggle)
php-doctrine-annotations 1.11.2-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,028 kB
  • sloc: php: 8,480; makefile: 19
file content (64 lines) | stat: -rw-r--r-- 1,762 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

declare(strict_types=1);

namespace Doctrine\Performance\Common\Annotations;

use Doctrine\Common\Annotations\DocParser;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;

use function array_fill_keys;

/**
 * @BeforeMethods({"initializeMethod", "initialize"})
 */
final class DocParserPerformanceBench
{
    use MethodInitializer;

    private const IMPORTS = [
        'ignorephpdoc'     => 'Annotations\Annotation\IgnorePhpDoc',
        'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation',
        'route'            => Route::class,
        'template'         => Template::class,
        '__NAMESPACE__'    => 'Doctrine\Tests\Common\Annotations\Fixtures',
    ];

    private const IGNORED = [
        'access', 'author', 'copyright', 'deprecated', 'example', 'ignore',
        'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package',
        'subpackage', 'name', 'global', 'param', 'return', 'staticvar',
        'static', 'var', 'throws', 'inheritdoc',
    ];

    /** @var DocParser */
    private $parser;

    public function initialize(): void
    {
        $this->parser = new DocParser();

        $this->parser->setImports(self::IMPORTS);
        $this->parser->setIgnoredAnnotationNames(array_fill_keys(self::IGNORED, true));
        $this->parser->setIgnoreNotImportedAnnotations(true);
    }

    /**
     * @Revs(200)
     * @Iterations(5)
     */
    public function benchMethodParsing(): void
    {
        $this->parser->parse($this->methodDocBlock);
    }

    /**
     * @Revs(200)
     * @Iterations(5)
     */
    public function benchClassParsing(): void
    {
        $this->parser->parse($this->classDocBlock);
    }
}