|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DoctrineTest\InstantiatorPerformance; |
|
4
|
|
|
|
|
5
|
|
|
use ArrayObject; |
|
6
|
|
|
use Doctrine\Instantiator\Instantiator; |
|
7
|
|
|
use DoctrineTest\InstantiatorTestAsset\SerializableArrayObjectAsset; |
|
8
|
|
|
use DoctrineTest\InstantiatorTestAsset\SimpleSerializableAsset; |
|
9
|
|
|
use DoctrineTest\InstantiatorTestAsset\UnCloneableAsset; |
|
10
|
|
|
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; |
|
11
|
|
|
use PhpBench\Benchmark\Metadata\Annotations\Revs; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Performance tests for {@see \Doctrine\Instantiator\Instantiator} |
|
15
|
|
|
* |
|
16
|
|
|
* @BeforeMethods({"init"}) |
|
17
|
|
|
*/ |
|
18
|
|
|
class InstantiatorPerformanceEvent |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var Instantiator */ |
|
21
|
|
|
private $instantiator; |
|
22
|
|
|
|
|
23
|
|
|
public function init() : void |
|
24
|
|
|
{ |
|
25
|
|
|
$this->instantiator = new Instantiator(); |
|
26
|
|
|
|
|
27
|
|
|
$this->instantiator->instantiate(self::class); |
|
28
|
|
|
$this->instantiator->instantiate(ArrayObject::class); |
|
29
|
|
|
$this->instantiator->instantiate(SimpleSerializableAsset::class); |
|
30
|
|
|
$this->instantiator->instantiate(SerializableArrayObjectAsset::class); |
|
31
|
|
|
$this->instantiator->instantiate(UnCloneableAsset::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @Revs(20000) |
|
36
|
|
|
*/ |
|
37
|
|
|
public function benchInstantiateSelf() : void |
|
38
|
|
|
{ |
|
39
|
|
|
$this->instantiator->instantiate(self::class); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @Revs(20000) |
|
44
|
|
|
*/ |
|
45
|
|
|
public function benchInstantiateInternalClass() : void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->instantiator->instantiate(ArrayObject::class); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @Revs(20000) |
|
52
|
|
|
*/ |
|
53
|
|
|
public function benchInstantiateSimpleSerializableAssetClass() : void |
|
54
|
|
|
{ |
|
55
|
|
|
$this->instantiator->instantiate(SimpleSerializableAsset::class); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @Revs(20000) |
|
60
|
|
|
*/ |
|
61
|
|
|
public function benchInstantiateSerializableArrayObjectAsset() : void |
|
62
|
|
|
{ |
|
63
|
|
|
$this->instantiator->instantiate(SerializableArrayObjectAsset::class); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @Revs(20000) |
|
68
|
|
|
*/ |
|
69
|
|
|
public function benchInstantiateUnCloneableAsset() : void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->instantiator->instantiate(UnCloneableAsset::class); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|