Created
August 24, 2016 11:02
-
-
Save GeeH/ad03958521c8481be5e94e1a22556182 to your computer and use it in GitHub Desktop.
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 | |
namespace ZendBench\ServiceManager; | |
use ProxyManager\Factory\LazyLoadingValueHolderFactory; | |
use Zend\ServiceManager\Proxy\LazyServiceFactory; | |
use ZendTest\ServiceManager\TestAsset\ComplexDependencyObject; | |
use ZendTest\ServiceManager\TestAsset\FailingFactory; | |
use ZendTest\ServiceManager\TestAsset\InvokableObject; | |
use ZendTest\ServiceManager\TestAsset\SimpleDependencyObject; | |
/** | |
* @Revs(1000) | |
* @Iterations(30) | |
* @Warmup(2) | |
*/ | |
class TestArgumentUnpackingBench | |
{ | |
public function benchTraditionalArguments() | |
{ | |
$simpleDependencyObject = new SimpleDependencyObject(new InvokableObject(), new FailingFactory()); | |
$lazyServiceFactory = new LazyServiceFactory(new LazyLoadingValueHolderFactory(), []); | |
$complexObject = new ComplexDependencyObject($simpleDependencyObject, $lazyServiceFactory); | |
} | |
public function benchArgumentUnpacking() | |
{ | |
$arguments = [new InvokableObject(), new FailingFactory()]; | |
$simpleDependencyObject = new SimpleDependencyObject(...$arguments); | |
$arguments = [new LazyLoadingValueHolderFactory(), []]; | |
$lazyServiceFactory = new LazyServiceFactory(...$arguments); | |
$arguments = [$simpleDependencyObject, $lazyServiceFactory]; | |
$complexObject = new ComplexDependencyObject(...$arguments); | |
} | |
} |
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
benchTraditionalArguments R2 I15 P0 [μ Mo]/r: 1.009 1.011 (μs) [μSD μRSD]/r: 0.023μs 2.33% | |
benchArgumentUnpacking R1 I25 P0 [μ Mo]/r: 1.270 1.287 (μs) [μSD μRSD]/r: 0.029μs 2.24% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment