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

TypeResolverBench::benchResolveCompoundType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
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 benchmark;
6
7
use phpDocumentor\Reflection\TypeResolver;
8
9
/**
10
 * @BeforeMethods({"setup"})
11
 */
12
class TypeResolverBench
13
{
14
    private $typeResolver;
15
16
    public function setup()
17
    {
18
        $this->typeResolver = new TypeResolver();
19
    }
20
21
    /**
22
     * @Warmup(2)
23
     * @Revs(10000)
24
     * @Executor(
25
     *     "blackfire",
26
     *     assertions={
27
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
28
     *      "main.wall_time < 300us"
29
     *      }
30
     * )
31
     */
32
    public function benchResolveSingleType() : void
33
    {
34
        $this->typeResolver->resolve('string');
35
    }
36
37
    /**
38
     * @Warmup(2)
39
     * @Revs(10000)
40
     * @Executor(
41
     *     "blackfire",
42
     *     assertions={
43
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
44
     *      "main.wall_time < 0.5ms"
45
     *      }
46
     * )
47
     */
48
    public function benchResolveCompoundType() : void
49
    {
50
        $this->typeResolver->resolve('string|int|bool');
51
    }
52
53
    /**
54
     * @Warmup(2)
55
     * @Revs(10000)
56
     * @Executor(
57
     *     "blackfire",
58
     *     assertions={
59
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
60
     *      "main.wall_time < 300us"
61
     *      }
62
     * )
63
     */
64
    public function benchResolveArrayType() : void
65
    {
66
        $this->typeResolver->resolve('string[]');
67
    }
68
69
    /**
70
     * @Warmup(2)
71
     * @Revs(10000)
72
     * @Executor(
73
     *     "blackfire",
74
     *     assertions={
75
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
76
     *      "main.wall_time < 300us"
77
     *      }
78
     * )
79
     */
80
    public function benchResolveCompoundArrayType() : void
81
    {
82
        $this->typeResolver->resolve('(string|int)[]');
83
    }
84
85
    /**
86
     * @Warmup(2)
87
     * @Revs(10000)
88
     * @Executor(
89
     *     "blackfire",
90
     *     assertions={
91
     *      {"expression"="main.peak_memory < 11kb", "title"="memory peak"},
92
     *      "main.wall_time < 1ms"
93
     *      }
94
     * )
95
     */
96
    public function benchResolveCompoundArrayWithDefinedTypes() : void
97
    {
98
        $this->typeResolver->resolve('array<int, string>|array<int, int>');
99
    }
100
}
101