Full hydration + query benchmark
This commit is contained in:
parent
f95c81b210
commit
88ea1d33fa
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Performance\Hydration;
|
||||||
|
|
||||||
|
use Doctrine\Common\Persistence\ObjectRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\Performance\EntityManagerFactory;
|
||||||
|
use Doctrine\Tests\Models\CMS\CmsUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BeforeMethods({"init"})
|
||||||
|
*/
|
||||||
|
final class SimpleHydrationBench
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var EntityManagerInterface
|
||||||
|
*/
|
||||||
|
private $entityManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ObjectRepository
|
||||||
|
*/
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->entityManager = EntityManagerFactory::getEntityManager([
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsUser::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsPhonenumber::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsAddress::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsEmail::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsGroup::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsTag::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsArticle::class,
|
||||||
|
\Doctrine\Tests\Models\CMS\CmsComment::class,
|
||||||
|
]);
|
||||||
|
|
||||||
|
for ($i = 2; $i < 10000; ++$i) {
|
||||||
|
$user = new CmsUser();
|
||||||
|
|
||||||
|
$user->status = 'developer';
|
||||||
|
$user->username = 'jwage' . $i;
|
||||||
|
$user->name = 'Jonathan';
|
||||||
|
|
||||||
|
$this->entityManager->persist($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
$this->entityManager->clear();
|
||||||
|
|
||||||
|
$this->repository = $this->entityManager->getRepository(CmsUser::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function benchSimpleFindOperationHydration()
|
||||||
|
{
|
||||||
|
$this->repository->findAll();
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
||||||
|
|
||||||
use Doctrine\Tests\Models\CMS\CmsUser;
|
|
||||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group DDC-1050
|
|
||||||
*/
|
|
||||||
class DDC1050Test extends OrmFunctionalTestCase
|
|
||||||
{
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->markTestSkipped('performance skipped');
|
|
||||||
|
|
||||||
$this->useModelSet('cms');
|
|
||||||
|
|
||||||
parent::setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPerformance()
|
|
||||||
{
|
|
||||||
for ($i = 2; $i < 10000; ++$i) {
|
|
||||||
$user = new CmsUser();
|
|
||||||
$user->status = 'developer';
|
|
||||||
$user->username = 'jwage'.$i;
|
|
||||||
$user->name = 'Jonathan';
|
|
||||||
$this->_em->persist($user);
|
|
||||||
}
|
|
||||||
$this->_em->flush();
|
|
||||||
$this->_em->clear();
|
|
||||||
|
|
||||||
$s = microtime(true);
|
|
||||||
$users = $this->_em->getRepository(CmsUser::class)->findAll();
|
|
||||||
$e = microtime(true);
|
|
||||||
echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user