Skip to content

Instantly share code, notes, and snippets.

@SchumacherFM
Created December 28, 2014 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SchumacherFM/7fa66882520c3ccffaa4 to your computer and use it in GitHub Desktop.
Save SchumacherFM/7fa66882520c3ccffaa4 to your computer and use it in GitHub Desktop.
Magento2 Dependency Injection Speed Tester
<pre><?php
// call via http://mage2.dev/DISpeedTest.php
// change settings in app/etc/config.php
require('app/autoload.php');
Zend_Debug::dump(ini_get('memory_limit')); // should be > 1536MB
$start = microtime(true);
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
for ($i = 0; $i < 100; $i++) {
$om = $bootstrap->getObjectManager();
$om = null;
$bootstrap->unsetObjectManager(); // must be implemented by yourself in Magento\Framework\App\Bootstrap.php
}
printf(
"\nDuration for %s: %.6f secs\n",
$bootstrap->getObjectManager()->get('Magento\Framework\App\DeploymentConfig')->get('definition/format'),
microtime(true) - $start
);
echo "\nDone\n";
//$scripts = opcache_get_status(true);
//foreach($scripts['scripts'] as $script){
// echo $script['full_path']."\n";
// if(
// strstr($script['full_path'],'DISpeedTest')!==false ||
// strstr($script['full_path'],'definitions.php')!==false
// ){
// Zend_Debug::dump($script);
// }
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment