This test is just to show off how performance bottlenecks can be cut down by using a DIC compiler for Zend\Di\Di
. The test has been executed with DoctrineModule
enabled on a standard ZendSkeletonApplication
. You can look at the code that generated this locator at https://github.com/Ocramius/zf2/tree/feature/di-compiler .
The test simply runs following once:
./vendor/doctrine/DoctrineModule/bin/doctrine
The tests have been executed by directly replace Zend\Di\Di
instantiation with the (attached) compiled Di proxy in Zend\Mvc\Bootstrap::setupLocator
.
The cachegrind results for the two tests are attached, cachegrind.out.10696
is without the compiled DIC, while cachegrind.out.10713
is the result of the run with the compiled DIC proxy.
The difference, in terms of execution time, is quite small for this use case (9 seconds for 100 iterations without compiled DIC vs 7 seconds for 100 iterations with compiled DIC proxy). These differences grow a lot when the complexity of the DIC configuration grows.
The Compiled DIC still doesn't work with Zend\Mvc\Application
, nor completely exclude the original DIC, that is why I wrote this other way of testing. If you can find out why, you get a medal :D
Anyway, it is related with type preferences in the DIC, which don't really work for now, and break Application\Dic\Compiled::getZendMvcControllerPluginBroker
.
You can anyway notice that the xdebug dump produced by Zend\Di\Di
is 3Mb, vs 1.2Mb of the Application\Dic\Compiled
dump.