Failed Conditions
Push — master ( 9826d9...840795 )
by Luís
18s
created

benchCmsUserInstantiation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
namespace Doctrine\Performance\LazyLoading;
4
5
use Doctrine\Common\Proxy\AbstractProxyFactory;
6
use Doctrine\Performance\EntityManagerFactory;
7
use Doctrine\Tests\Models\CMS\CmsEmployee;
8
use Doctrine\Tests\Models\CMS\CmsUser;
9
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
10
11
/**
12
 * @BeforeMethods({"init"})
13
 */
14
final class ProxyInstantiationTimeBench
15
{
16
    /**
17
     * @var AbstractProxyFactory
18
     */
19
    private $proxyFactory;
20
21
    public function init()
22
    {
23
        $this->proxyFactory = EntityManagerFactory::getEntityManager([])->getProxyFactory();
24
    }
25
26
    public function benchCmsUserInstantiation()
27
    {
28
        for ($i = 0; $i < 100000; ++$i) {
29
            $this->proxyFactory->getProxy(CmsUser::class, ['id' => $i]);
30
        }
31
    }
32
33
    public function benchCmsEmployeeInstantiation()
34
    {
35
        for ($i = 0; $i < 100000; ++$i) {
36
            $this->proxyFactory->getProxy(CmsEmployee::class, ['id' => $i]);
37
        }
38
    }
39
}
40
41