Created
September 15, 2015 08:10
-
-
Save rivetmichael/b31505d7b8f0dc36bad9 to your computer and use it in GitHub Desktop.
A simple comparison between reflection instantiation and new object instantiation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/app/bootstrap.php'; | |
$config = [ | |
'drivers' => [ | |
[ | |
'output' => [ | |
'type' => 'html', | |
'thresholds' => [ | |
'sum' => 0 | |
] | |
] | |
] | |
], | |
'driverFactory' | |
]; | |
Magento\Framework\Profiler::applyConfig($config, BP); | |
Magento\Framework\Profiler::enable(); | |
for ($cpt = 0;$cpt < 1000000; $cpt++) { | |
Magento\Framework\Profiler::start('__reflection__'); | |
$r = new \ReflectionClass('Pulsestorm\TutorialProxy1\Model\Message'); | |
Magento\Framework\Profiler::stop('__reflection__'); | |
unset($r); | |
} | |
for ($cpt = 0;$cpt < 1000000; $cpt++) { | |
Magento\Framework\Profiler::start('__plain old new__'); | |
$r = new Pulsestorm\TutorialProxy1\Model\Message; | |
Magento\Framework\Profiler::stop('__plain old new__'); | |
unset($r); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment