From d8140d700ac40d4d8d165a89ca8182ec5ab98c6c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 26 May 2016 23:02:26 +0200 Subject: [PATCH] Benchmarking proxy initialization logic --- .../ProxyInitializationTimeBench.php | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php new file mode 100644 index 000000000..aeb5a1d2d --- /dev/null +++ b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php @@ -0,0 +1,81 @@ +getProxyFactory(); + + for ($i = 0; $i < 10000; ++$i) { + $this->cmsUsers[$i] = $proxyFactory->getProxy(CmsUser::class, ['id' => $i]); + $this->cmsEmployees[$i] = $proxyFactory->getProxy(CmsEmployee::class, ['id' => $i]); + $this->initializedUsers[$i] = $proxyFactory->getProxy(CmsUser::class, ['id' => $i]); + $this->initializedEmployees[$i] = $proxyFactory->getProxy(CmsEmployee::class, ['id' => $i]); + + $this->initializedUsers[$i]->__load(); + $this->initializedEmployees[$i]->__load(); + } + } + + public function benchCmsUserInitialization() + { + foreach ($this->cmsUsers as $proxy) { + $proxy->__load(); + } + } + + public function benchCmsEmployeeInitialization() + { + foreach ($this->cmsEmployees as $proxy) { + $proxy->__load(); + } + } + + public function benchInitializationOfAlreadyInitializedCmsUsers() + { + foreach ($this->initializedUsers as $proxy) { + $proxy->__load(); + } + } + + public function benchInitializationOfAlreadyInitializedCmsEmployees() + { + foreach ($this->initializedEmployees as $proxy) { + $proxy->__load(); + } + } +} +