1
0
mirror of synced 2025-02-02 21:41:45 +03:00

Correcting the SimpleInsertPerformanceBench, which was running into duplicate record integrity constraint violations when run with >1 revs

This commit is contained in:
Marco Pivetta 2017-08-26 16:41:03 +02:00
parent 7a0385634f
commit e1e7485e58
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629

View File

@ -3,9 +3,7 @@
namespace Doctrine\Performance\Hydration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\Performance\EntityManagerFactory;
use Doctrine\Tests\Mocks\HydratorMockStatement;
use Doctrine\Tests\Models\CMS;
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
@ -24,6 +22,11 @@ final class SimpleInsertPerformanceBench
*/
private $users;
/**
* @var string
*/
private $tableName;
public function init()
{
$this->entityManager = EntityManagerFactory::getEntityManager([
@ -45,10 +48,17 @@ final class SimpleInsertPerformanceBench
$this->users[$i] = $user;
}
$this->tableName = $this->entityManager->getClassMetadata(CMS\CmsUser::class)->getTableName();
}
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) {
$this->entityManager->persist($user);