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

ProxyInstantiationTimeBench   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A benchCmsUserInstantiation() 0 6 2
A benchCmsEmployeeInstantiation() 0 6 2
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