-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
249 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Emonkak\Di\Benchmarks; | ||
|
||
use Athletic\AthleticEvent; | ||
use Auryn\Injector; | ||
use Emonkak\Di\Benchmarks\Fixtures\Foo; | ||
|
||
class AurynDiEvent extends AthleticEvent | ||
{ | ||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function get() | ||
{ | ||
$injector = new Injector(); | ||
|
||
$injector->alias('Emonkak\Di\Benchmarks\Fixtures\FooInterface', 'Emonkak\Di\Benchmarks\Fixtures\Foo'); | ||
$injector->alias('Emonkak\Di\Benchmarks\Fixtures\BarInterface', 'Emonkak\Di\Benchmarks\Fixtures\Bar'); | ||
$injector->alias('Emonkak\Di\Benchmarks\Fixtures\BazInterface', 'Emonkak\Di\Benchmarks\Fixtures\Baz'); | ||
|
||
$foo = $injector->make('Emonkak\Di\Benchmarks\Fixtures\FooInterface'); | ||
assert($foo instanceof Foo); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Emonkak\Di\Benchmarks; | ||
|
||
use Athletic\AthleticEvent; | ||
use Brick\Di\Container; | ||
use Brick\Di\InjectionPolicy; | ||
use Emonkak\Di\Benchmarks\Fixtures\Foo; | ||
|
||
if (version_compare(PHP_VERSION, '5.5', '<')) { | ||
class BrickDiEvent extends AthleticEvent | ||
{ | ||
} | ||
} else { | ||
class BrickDiEvent extends AthleticEvent | ||
{ | ||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function get() | ||
{ | ||
$container = new Container(new MyPolicy()); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\FooInterface')->to('Emonkak\Di\Benchmarks\Fixtures\Foo'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BarInterface')->to('Emonkak\Di\Benchmarks\Fixtures\Bar'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BazInterface')->to('Emonkak\Di\Benchmarks\Fixtures\Baz'); | ||
$foo = $container->get('Emonkak\Di\Benchmarks\Fixtures\FooInterface'); | ||
assert($foo instanceof Foo); | ||
} | ||
} | ||
} | ||
|
||
class MyPolicy implements InjectionPolicy | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isClassInjected(\ReflectionClass $class) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isMethodInjected(\ReflectionMethod $method) | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isPropertyInjected(\ReflectionProperty $property) | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getParameterKey(\ReflectionParameter $parameter) | ||
{ | ||
return $parameter->getClass()->name; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPropertyKey(\ReflectionProperty $property) | ||
{ | ||
return $property->getClass()->name; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Emonkak\Di\Benchmarks; | ||
|
||
use Athletic\AthleticEvent; | ||
use Emonkak\Di\Benchmarks\Fixtures\Foo; | ||
use Illuminate\Container\Container; | ||
|
||
class IlluminateContainerEvent extends AthleticEvent | ||
{ | ||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function get() | ||
{ | ||
$container = new Container(); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\FooInterface', 'Emonkak\Di\Benchmarks\Fixtures\Foo'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BarInterface', 'Emonkak\Di\Benchmarks\Fixtures\Bar'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BazInterface', 'Emonkak\Di\Benchmarks\Fixtures\Baz'); | ||
$foo = $container->make('Emonkak\Di\Benchmarks\Fixtures\FooInterface'); | ||
assert($foo instanceof Foo); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Emonkak\Di\Benchmarks; | ||
|
||
use Athletic\AthleticEvent; | ||
use Emonkak\Di\Benchmarks\Fixtures\Foo; | ||
use League\Di\Container; | ||
|
||
class LeagueDiEvent extends AthleticEvent | ||
{ | ||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function get() | ||
{ | ||
$container = new Container(); | ||
|
||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\FooInterface', 'Emonkak\Di\Benchmarks\Fixtures\Foo'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BarInterface', 'Emonkak\Di\Benchmarks\Fixtures\Bar'); | ||
$container->bind('Emonkak\Di\Benchmarks\Fixtures\BazInterface', 'Emonkak\Di\Benchmarks\Fixtures\Baz'); | ||
|
||
$foo = $container->resolve('Emonkak\Di\Benchmarks\Fixtures\FooInterface'); | ||
assert($foo instanceof Foo); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Emonkak\Di\Benchmarks; | ||
|
||
use Athletic\AthleticEvent; | ||
use Auryn\Injector; | ||
use Emonkak\Di\Benchmarks\Fixtures\Foo; | ||
use Zend\Di\Di; | ||
|
||
class ZendDiEvent extends AthleticEvent | ||
{ | ||
/** | ||
* @iterations 1000 | ||
*/ | ||
public function get() | ||
{ | ||
$di = new Di(); | ||
|
||
$di->instanceManager() | ||
->addTypePreference('Emonkak\Di\Benchmarks\Fixtures\FooInterface', 'Emonkak\Di\Benchmarks\Fixtures\Foo') | ||
->addTypePreference('Emonkak\Di\Benchmarks\Fixtures\BarInterface', 'Emonkak\Di\Benchmarks\Fixtures\Bar') | ||
->addTypePreference('Emonkak\Di\Benchmarks\Fixtures\BazInterface', 'Emonkak\Di\Benchmarks\Fixtures\Baz'); | ||
|
||
$foo = $di->get('Emonkak\Di\Benchmarks\Fixtures\Foo'); | ||
assert($foo instanceof Foo); | ||
} | ||
} |
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