|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* GpsLab component. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Peter Gribanov <[email protected]> |
|
7
|
|
|
* @copyright Copyright (c) 2017, Peter Gribanov |
|
8
|
|
|
* @license http://opensource.org/licenses/MIT |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace GpsLab\Component\Enum\Bench\Compare\Operation; |
|
12
|
|
|
|
|
13
|
|
|
use GpsLab\Component\Enum\Bench\Compare\CompareEnumBench; |
|
14
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\AbcExp; |
|
15
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\AbcRef; |
|
16
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\DefRef; |
|
17
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcHappyTypes; |
|
18
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcMarcMabe; |
|
19
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcMyClabs; |
|
20
|
|
|
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\DefMarcMabe; |
|
21
|
|
|
use PhpBench\Benchmark\Metadata\Annotations\Iterations; |
|
22
|
|
|
use PhpBench\Benchmark\Metadata\Annotations\Revs; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @Revs(2500) |
|
26
|
|
|
* @Iterations(25) |
|
27
|
|
|
*/ |
|
28
|
|
|
class CompareDifferentEnumBench implements CompareEnumBench |
|
29
|
|
|
{ |
|
30
|
|
|
public function benchReflectionEnum() |
|
31
|
|
|
{ |
|
32
|
|
|
AbcRef::A()->equals(AbcRef::B()); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function benchReflectionEnumNoMagic() |
|
36
|
|
|
{ |
|
37
|
|
|
DefRef::byValue(DefRef::D)->equals(DefRef::byValue(DefRef::E)); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function benchExplicitEnum() |
|
41
|
|
|
{ |
|
42
|
|
|
AbcExp::byValue(AbcExp::A)->equals(AbcExp::byValue(AbcExp::B)); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function benchMyCLabsEnum() |
|
46
|
|
|
{ |
|
47
|
|
|
AbcMyClabs::A()->equals(AbcMyClabs::B()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function benchMabeEnum() |
|
51
|
|
|
{ |
|
52
|
|
|
AbcMarcMabe::A()->is(AbcMarcMabe::B()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function benchMabeNoMagicEnum() |
|
56
|
|
|
{ |
|
57
|
|
|
DefMarcMabe::byValue(DefMarcMabe::D)->is(DefMarcMabe::byValue(DefMarcMabe::E)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function benchHappyTypesEnum() |
|
61
|
|
|
{ |
|
62
|
|
|
AbcHappyTypes::A()->equals(AbcHappyTypes::B()); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|