From e1e7485e587374707dc4d72499d5197793e98f42 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 26 Aug 2017 16:41:03 +0200 Subject: [PATCH] Correcting the `SimpleInsertPerformanceBench`, which was running into duplicate record integrity constraint violations when run with >1 revs --- .../Hydration/SimpleInsertPerformanceBench.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php index 68a933dd3..5806b6b9d 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php @@ -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);