Skip to content

Instantly share code, notes, and snippets.

@GeeH
Created August 24, 2016 11:02
Show Gist options
  • Save GeeH/ad03958521c8481be5e94e1a22556182 to your computer and use it in GitHub Desktop.
Save GeeH/ad03958521c8481be5e94e1a22556182 to your computer and use it in GitHub Desktop.
<?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);
}
}
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