Correcting the SimpleInsertPerformanceBench
, which was running into duplicate record integrity constraint violations when run with >1 revs
This commit is contained in:
parent
7a0385634f
commit
e1e7485e58
@ -3,9 +3,7 @@
|
|||||||
namespace Doctrine\Performance\Hydration;
|
namespace Doctrine\Performance\Hydration;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Doctrine\Performance\EntityManagerFactory;
|
use Doctrine\Performance\EntityManagerFactory;
|
||||||
use Doctrine\Tests\Mocks\HydratorMockStatement;
|
|
||||||
use Doctrine\Tests\Models\CMS;
|
use Doctrine\Tests\Models\CMS;
|
||||||
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
|
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
|
||||||
|
|
||||||
@ -24,6 +22,11 @@ final class SimpleInsertPerformanceBench
|
|||||||
*/
|
*/
|
||||||
private $users;
|
private $users;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $tableName;
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->entityManager = EntityManagerFactory::getEntityManager([
|
$this->entityManager = EntityManagerFactory::getEntityManager([
|
||||||
@ -45,10 +48,17 @@ final class SimpleInsertPerformanceBench
|
|||||||
|
|
||||||
$this->users[$i] = $user;
|
$this->users[$i] = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->tableName = $this->entityManager->getClassMetadata(CMS\CmsUser::class)->getTableName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function benchHydration()
|
public function benchHydration()
|
||||||
{
|
{
|
||||||
|
// Yes, this is a lot of overhead, but I have no better solution other than
|
||||||
|
// completely mocking out the DB, which would be silly (query impact is
|
||||||
|
// necessarily part of our benchmarks)
|
||||||
|
$this->entityManager->getConnection()->executeQuery('DELETE FROM ' . $this->tableName)->execute();
|
||||||
|
|
||||||
foreach ($this->users as $key => $user) {
|
foreach ($this->users as $key => $user) {
|
||||||
$this->entityManager->persist($user);
|
$this->entityManager->persist($user);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user