From 97735cdb68db18a76779886d0d061ec0a1e03763 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 26 May 2016 21:12:43 +0200 Subject: [PATCH] Partial hydration bench --- ...PartialObjectHydrationPerformanceBench.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php new file mode 100644 index 000000000..cbbc24e1b --- /dev/null +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -0,0 +1,83 @@ + '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ], + [ + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ], + [ + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ] + ]; + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = [ + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + ]; + } + + $this->stmt = new HydratorMockStatement($resultSet); + $this->hydrator = new ObjectHydrator($entityManager); + $this->rsm = new ResultSetMapping; + + $this->rsm->addEntityResult(CmsUser::class, 'u'); + $this->rsm->addFieldResult('u', 'u__id', 'id'); + $this->rsm->addFieldResult('u', 'u__status', 'status'); + $this->rsm->addFieldResult('u', 'u__username', 'username'); + $this->rsm->addFieldResult('u', 'u__name', 'name'); + } + + public function benchHydration() + { + $this->hydrator->hydrateAll($this->stmt, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); + } +} +