diff --git a/DiMaria/test1.php b/DiMaria/test1.php
new file mode 100644
index 0000000..3a6836e
--- /dev/null
+++ b/DiMaria/test1.php
@@ -0,0 +1,18 @@
+create('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/DiMaria/test2.php b/DiMaria/test2.php
new file mode 100644
index 0000000..dac58f3
--- /dev/null
+++ b/DiMaria/test2.php
@@ -0,0 +1,20 @@
+get('A');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->create('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/DiMaria/test3.php b/DiMaria/test3.php
new file mode 100644
index 0000000..5573362
--- /dev/null
+++ b/DiMaria/test3.php
@@ -0,0 +1,20 @@
+get('J');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->create('J');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/DiMaria/test4.php b/DiMaria/test4.php
new file mode 100644
index 0000000..06d87f1
--- /dev/null
+++ b/DiMaria/test4.php
@@ -0,0 +1,17 @@
+get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/DiMaria/test5.php b/DiMaria/test5.php
new file mode 100644
index 0000000..7d15b30
--- /dev/null
+++ b/DiMaria/test5.php
@@ -0,0 +1,19 @@
+setShared('A');
+$b = $di->create('B');
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di->create('B');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/DiMaria/test6.php b/DiMaria/test6.php
new file mode 100644
index 0000000..b152e76
--- /dev/null
+++ b/DiMaria/test6.php
@@ -0,0 +1,16 @@
+create('J');
+}
+
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/DiMaria/test6a.php b/DiMaria/test6a.php
new file mode 100644
index 0000000..fb14ec4
--- /dev/null
+++ b/DiMaria/test6a.php
@@ -0,0 +1,14 @@
+create('J');
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/README.md b/README.md
index 31b2344..bd90681 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,27 @@
# DI Container Benchmarks
Containers currently tested are:
-- Aura
-- Auryn
-- Dice
-- Laravel
-- Leage
-- Njasm
-- Phalcon
-- PHP-DI
-- Pimple
-- Symfony DI
-- Zend\Di
-- Zend\Servicemanager
-
-
-**Nette is currently disabled due to not working as advertised. It fails to load Nette\DI\ContainerLoader which prevents any tests being done**
+- [Aura.Di](ttps://github.com/auraphp/Aura.Di)
+- [Auryn](https://github.com/rdlowrey/auryn)
+- [Chernozem](https://github.com/pyrsmk/Chernozem)
+- [Di52](https://github.com/lucatume/di52)
+- [Dice](http://r.je/dice.html)
+- [DiMaria](https://github.com/dangerousdan/dimaria)
+- [Joomla DI](https://github.com/joomla-framework/di)
+- [Laravel](https://github.com/illuminate/container)
+- [Leage](https://github.com/thephpleague/container)
+- [Nette](https://github.com/nette/di)
+- [Njasm](https://github.com/njasm/container)
+- [Phalcon](https://docs.phalconphp.com/en/3.2/di)
+- [PHP-DI](http://php-di.org/)
+- [Pimple](http://pimple.sensiolabs.org)
+- [Slince DI](https://github.com/slince/di)
+- [Symfony DI](https://github.com/symfony/dependency-injection)
+- [Unbox](https://github.com/mindplay-dk/unbox)
+- [Yii2-di](http://www.yiiframework.com/doc-2.0/guide-concept-di-container.html)
+- [Zend\Di](https://github.com/zendframework/zend-di)
+- [Zend\Servicemanager](https://github.com/zendframework/zend-servicemanager)
+
**Ray.Di does not seem to work without annotations. Requiring the classes to be coupled to the container goes against the spirit of DI and as such is not tested here**
diff --git a/aura/test1.php b/aura/test1.php
index 7f1d6c2..0c3ab8b 100644
--- a/aura/test1.php
+++ b/aura/test1.php
@@ -2,9 +2,9 @@
$t1 = microtime(true);
-use Aura\Di\Container;
-use Aura\Di\Factory;
-$di = new Container(new Factory());
+use Aura\Di\ContainerBuilder;
+$builder = new ContainerBuilder();
+$di = $builder->newInstance();
$di->set('A', $di->lazyNew('A'));
for ($i = 0; $i < 10000; $i++) {
diff --git a/aura/test2.php b/aura/test2.php
index a93a7fc..9c3b7dd 100644
--- a/aura/test2.php
+++ b/aura/test2.php
@@ -1,9 +1,9 @@
newInstance();
$di->set('A', $di->lazyNew('A'));
diff --git a/aura/test3.php b/aura/test3.php
index ab72af0..a8f7d6e 100644
--- a/aura/test3.php
+++ b/aura/test3.php
@@ -1,9 +1,9 @@
newInstance();
$di->params['J'] = ['i' => $di->lazyNew('I')];
diff --git a/aura/test4.php b/aura/test4.php
index 5f22361..ff38583 100644
--- a/aura/test4.php
+++ b/aura/test4.php
@@ -1,8 +1,8 @@
newInstance();
$di->set('A', $di->lazyNew('A'));
diff --git a/aura/test5.php b/aura/test5.php
index d0235e5..5ed3709 100644
--- a/aura/test5.php
+++ b/aura/test5.php
@@ -1,14 +1,14 @@
newInstance();
$di->set('A', $di->lazyNew('A'));
+$di->params['B'] = ['a' => $di->lazyNew('A')];
$di->set('B', $di->lazyNew('B'));
-$di->params['B'] = ['a' => $di->get('A')];
//Trigger the autoloader before measuring execution time
$a = $di->newinstance('B');
diff --git a/aura/test6.php b/aura/test6.php
index 81ae13c..16e4dce 100644
--- a/aura/test6.php
+++ b/aura/test6.php
@@ -1,8 +1,8 @@
newInstance();
$di->params['J'] = ['i' => $di->lazyNew('I')];
diff --git a/aura/test6a.php b/aura/test6a.php
index 81ae13c..16e4dce 100644
--- a/aura/test6a.php
+++ b/aura/test6a.php
@@ -1,8 +1,8 @@
newInstance();
$di->params['J'] = ['i' => $di->lazyNew('I')];
diff --git a/auryn/test6.php b/auryn/test6.php
new file mode 100644
index 0000000..420503c
--- /dev/null
+++ b/auryn/test6.php
@@ -0,0 +1,14 @@
+make('J');
+}
+
+$results = [
+ 'time' => 0,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/auryn/test6a.php b/auryn/test6a.php
new file mode 100644
index 0000000..420503c
--- /dev/null
+++ b/auryn/test6a.php
@@ -0,0 +1,14 @@
+make('J');
+}
+
+$results = [
+ 'time' => 0,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test1.php b/chernozem/test1.php
new file mode 100644
index 0000000..9487ee3
--- /dev/null
+++ b/chernozem/test1.php
@@ -0,0 +1,21 @@
+factory(function($chernozem) {
+ return new A();
+});
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['A'];
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test2.php b/chernozem/test2.php
new file mode 100644
index 0000000..8fb281c
--- /dev/null
+++ b/chernozem/test2.php
@@ -0,0 +1,23 @@
+factory(function($chernozem) {
+ return new A();
+});
+//trigger autoloader for all required files
+$a = $chernozem['A'];
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['A'];
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test3.php b/chernozem/test3.php
new file mode 100644
index 0000000..2d48237
--- /dev/null
+++ b/chernozem/test3.php
@@ -0,0 +1,50 @@
+factory(function($chernozem) {
+ return new A();
+});
+$chernozem['B'] = $chernozem->factory(function($chernozem) {
+ return new B($chernozem['A']);
+});
+$chernozem['C'] = $chernozem->factory(function($chernozem) {
+ return new C($chernozem['B']);
+});
+$chernozem['D'] = $chernozem->factory(function($chernozem) {
+ return new D($chernozem['C']);
+});
+$chernozem['E'] = $chernozem->factory(function($chernozem) {
+ return new E($chernozem['D']);
+});
+$chernozem['F'] = $chernozem->factory(function($chernozem) {
+ return new F($chernozem['E']);
+});
+$chernozem['G'] = $chernozem->factory(function($chernozem) {
+ return new G($chernozem['F']);
+});
+$chernozem['H'] = $chernozem->factory(function($chernozem) {
+ return new H($chernozem['G']);
+});
+$chernozem['I'] = $chernozem->factory(function($chernozem) {
+ return new I($chernozem['H']);
+});
+$chernozem['J'] = $chernozem->factory(function($chernozem) {
+ return new J($chernozem['I']);
+});
+//trigger autoloader for all required files
+$a = $chernozem['J'];
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['J'];
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test4.php b/chernozem/test4.php
new file mode 100644
index 0000000..46580f9
--- /dev/null
+++ b/chernozem/test4.php
@@ -0,0 +1,19 @@
+ $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test5.php b/chernozem/test5.php
new file mode 100644
index 0000000..ddb9f37
--- /dev/null
+++ b/chernozem/test5.php
@@ -0,0 +1,21 @@
+factory(function($chernozem) {
+ return new B($chernozem['A']);
+});
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['B'];
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test6.php b/chernozem/test6.php
new file mode 100644
index 0000000..3336ba6
--- /dev/null
+++ b/chernozem/test6.php
@@ -0,0 +1,45 @@
+factory(function($chernozem) {
+ return new A();
+});
+$chernozem['B'] = $chernozem->factory(function($chernozem) {
+ return new B($chernozem['A']);
+});
+$chernozem['C'] = $chernozem->factory(function($chernozem) {
+ return new C($chernozem['B']);
+});
+$chernozem['D'] = $chernozem->factory(function($chernozem) {
+ return new D($chernozem['C']);
+});
+$chernozem['E'] = $chernozem->factory(function($chernozem) {
+ return new E($chernozem['D']);
+});
+$chernozem['F'] = $chernozem->factory(function($chernozem) {
+ return new F($chernozem['E']);
+});
+$chernozem['G'] = $chernozem->factory(function($chernozem) {
+ return new G($chernozem['F']);
+});
+$chernozem['H'] = $chernozem->factory(function($chernozem) {
+ return new H($chernozem['G']);
+});
+$chernozem['I'] = $chernozem->factory(function($chernozem) {
+ return new I($chernozem['H']);
+});
+$chernozem['J'] = $chernozem->factory(function($chernozem) {
+ return new J($chernozem['I']);
+});
+
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['J'];
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/chernozem/test6a.php b/chernozem/test6a.php
new file mode 100644
index 0000000..3336ba6
--- /dev/null
+++ b/chernozem/test6a.php
@@ -0,0 +1,45 @@
+factory(function($chernozem) {
+ return new A();
+});
+$chernozem['B'] = $chernozem->factory(function($chernozem) {
+ return new B($chernozem['A']);
+});
+$chernozem['C'] = $chernozem->factory(function($chernozem) {
+ return new C($chernozem['B']);
+});
+$chernozem['D'] = $chernozem->factory(function($chernozem) {
+ return new D($chernozem['C']);
+});
+$chernozem['E'] = $chernozem->factory(function($chernozem) {
+ return new E($chernozem['D']);
+});
+$chernozem['F'] = $chernozem->factory(function($chernozem) {
+ return new F($chernozem['E']);
+});
+$chernozem['G'] = $chernozem->factory(function($chernozem) {
+ return new G($chernozem['F']);
+});
+$chernozem['H'] = $chernozem->factory(function($chernozem) {
+ return new H($chernozem['G']);
+});
+$chernozem['I'] = $chernozem->factory(function($chernozem) {
+ return new I($chernozem['H']);
+});
+$chernozem['J'] = $chernozem->factory(function($chernozem) {
+ return new J($chernozem['I']);
+});
+
+for ($i = 0; $i < 10000; $i++) {
+ $a = $chernozem['J'];
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 623c538..6d2147b 100644
--- a/composer.json
+++ b/composer.json
@@ -26,6 +26,15 @@
"symfony/config": "*",
"symfony/proxy-manager-bridge": "*",
"zendframework/zend-di": "*",
- "zendframework/zend-servicemanager": "*"
- }
+ "zendframework/zend-servicemanager": "*",
+ "dangerousdan/dimaria": "*",
+ "mindplay/unbox": "*",
+ "slince/di": "*",
+ "joomla/di": "*",
+ "yiisoft/yii2": "*",
+ "lucatume/di52": "*",
+ "pyrsmk/chernozem": "*"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/di52/test1.php b/di52/test1.php
new file mode 100644
index 0000000..0ac50ac
--- /dev/null
+++ b/di52/test1.php
@@ -0,0 +1,19 @@
+make('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test2.php b/di52/test2.php
new file mode 100644
index 0000000..8d76e32
--- /dev/null
+++ b/di52/test2.php
@@ -0,0 +1,23 @@
+make('A');
+unset($a);
+
+$t1 = microtime(true);
+
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di52->make('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test3.php b/di52/test3.php
new file mode 100644
index 0000000..f2572a9
--- /dev/null
+++ b/di52/test3.php
@@ -0,0 +1,24 @@
+make('J');
+unset($a);
+
+
+$t1 = microtime(true);
+
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di52->make('J');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test4.php b/di52/test4.php
new file mode 100644
index 0000000..adeac8f
--- /dev/null
+++ b/di52/test4.php
@@ -0,0 +1,25 @@
+singleton('A', 'A');
+
+//Trigger all autoloaders
+$a = $di52->make('A');
+unset($a);
+
+$t1 = microtime(true);
+
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di52->make('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage() / 1024 / 1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test5.php b/di52/test5.php
new file mode 100644
index 0000000..16e1bc9
--- /dev/null
+++ b/di52/test5.php
@@ -0,0 +1,26 @@
+singleton('A', 'A');
+
+//Trigger all autoloaders
+$b = $di52->make('B');
+unset($b);
+
+
+$t1 = microtime(true);
+
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di52->make('B');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test6.php b/di52/test6.php
new file mode 100644
index 0000000..92e296f
--- /dev/null
+++ b/di52/test6.php
@@ -0,0 +1,15 @@
+make('J');
+}
+
+$results = [
+ 'time' => 0,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage() / 1024 / 1024,
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/di52/test6a.php b/di52/test6a.php
new file mode 100644
index 0000000..92e296f
--- /dev/null
+++ b/di52/test6a.php
@@ -0,0 +1,15 @@
+make('J');
+}
+
+$results = [
+ 'time' => 0,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage() / 1024 / 1024,
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test1.php b/joomla-di/test1.php
new file mode 100644
index 0000000..f622ca8
--- /dev/null
+++ b/joomla-di/test1.php
@@ -0,0 +1,19 @@
+buildObject('A', false);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->get('A', true);
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test2.php b/joomla-di/test2.php
new file mode 100644
index 0000000..af5bfa7
--- /dev/null
+++ b/joomla-di/test2.php
@@ -0,0 +1,18 @@
+buildObject('A', false);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->get('A', true);
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test3.php b/joomla-di/test3.php
new file mode 100644
index 0000000..9a8490a
--- /dev/null
+++ b/joomla-di/test3.php
@@ -0,0 +1,20 @@
+buildObject('J', false);
+$a = $di->get('J', true);
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('J', true);
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test4.php b/joomla-di/test4.php
new file mode 100644
index 0000000..015d12b
--- /dev/null
+++ b/joomla-di/test4.php
@@ -0,0 +1,18 @@
+buildObject('A', true);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test5.php b/joomla-di/test5.php
new file mode 100644
index 0000000..c38f74f
--- /dev/null
+++ b/joomla-di/test5.php
@@ -0,0 +1,19 @@
+buildObject('A', true);
+$di->buildObject('B', false);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di->get('B', true);
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/joomla-di/test6.php b/joomla-di/test6.php
new file mode 100644
index 0000000..32515b2
--- /dev/null
+++ b/joomla-di/test6.php
@@ -0,0 +1,17 @@
+buildObject('J', false);
+
+for ($i = 0; $i < $argv[1]; $i++) {
+ $j = $di->get('J', true);
+}
+
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/joomla-di/test6a.php b/joomla-di/test6a.php
new file mode 100644
index 0000000..6e26f8a
--- /dev/null
+++ b/joomla-di/test6a.php
@@ -0,0 +1,16 @@
+buildObject('J', false);
+
+for ($i = 0; $i < $argv[1]; $i++) {
+ $j = $di->get('J', true);
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/league/test1.php b/league/test1.php
index ddb6e36..b0cfe37 100644
--- a/league/test1.php
+++ b/league/test1.php
@@ -1,14 +1,11 @@
share('A');
for ($i = 0; $i < 10000; $i++) {
$a = $container->get('A');
}
-
$t2 = microtime(true);
$results = [
diff --git a/league/test2.php b/league/test2.php
index 047d1b3..cd7051c 100644
--- a/league/test2.php
+++ b/league/test2.php
@@ -1,19 +1,15 @@
share('A');
//trigger all autoloaders
$a = $container->get('A');
unset($a);
-
-
$t1 = microtime(true);
-
for ($i = 0; $i < 10000; $i++) {
$a = $container->get('A');
}
-
$t2 = microtime(true);
$results = [
diff --git a/league/test3.php b/league/test3.php
index 17493de..92449aa 100644
--- a/league/test3.php
+++ b/league/test3.php
@@ -2,15 +2,17 @@
//Trigger all autoloaders
$container = new League\Container\Container;
+// register the reflection container as a delegate to enable auto wiring
+$container->delegate(
+ new League\Container\ReflectionContainer
+);
$a = $container->get('J');
unset($a);
$t1 = microtime(true);
-
for ($i = 0; $i < 10000; $i++) {
$a = $container->get('J');
}
-
$t2 = microtime(true);
$results = [
diff --git a/league/test4.php b/league/test4.php
index fc4ef8a..3987a55 100644
--- a/league/test4.php
+++ b/league/test4.php
@@ -1,19 +1,19 @@
singleton('A');
-
+// register the reflection container as a delegate to enable auto wiring
+$container->delegate(
+ new League\Container\ReflectionContainer
+);
+$container->share('A');
//trigger all autoloaders
$a = $container->get('A');
unset($a);
$t1 = microtime(true);
-
-
for ($i = 0; $i < 10000; $i++) {
$a = $container->get('A');
}
-
$t2 = microtime(true);
$results = [
diff --git a/league/test5.php b/league/test5.php
index 5929f4a..feaf1cd 100644
--- a/league/test5.php
+++ b/league/test5.php
@@ -1,20 +1,19 @@
singleton('A');
-
+// register the reflection container as a delegate to enable auto wiring
+$container->delegate(
+ new League\Container\ReflectionContainer
+);
+$container->share('A');
//trigger all autoloaders
$b = $container->get('B');
unset($b);
$t1 = microtime(true);
-
-
for ($i = 0; $i < 10000; $i++) {
$a = $container->get('B');
}
-
$t2 = microtime(true);
$results = [
diff --git a/league/test6.php b/league/test6.php
index d39960a..8116292 100644
--- a/league/test6.php
+++ b/league/test6.php
@@ -1,8 +1,11 @@
delegate(
+ new League\Container\ReflectionContainer
+);
+
for ($i = 0; $i < $argv[1]; $i++) {
$j = $container->get('J');
}
diff --git a/league/test6a.php b/league/test6a.php
index eb098f7..8116292 100644
--- a/league/test6a.php
+++ b/league/test6a.php
@@ -1,6 +1,11 @@
delegate(
+ new League\Container\ReflectionContainer
+);
+
for ($i = 0; $i < $argv[1]; $i++) {
$j = $container->get('J');
}
diff --git a/nette/temp/Container_dcca481015.php b/nette/temp/Container_dcca481015.php
new file mode 100644
index 0000000..8dfb116
--- /dev/null
+++ b/nette/temp/Container_dcca481015.php
@@ -0,0 +1,121 @@
+ [
+ 'A' => [1 => ['a']],
+ 'B' => [1 => ['b']],
+ 'C' => [1 => ['c']],
+ 'D' => [1 => ['d']],
+ 'E' => [1 => ['e']],
+ 'F' => [1 => ['f']],
+ 'G' => [1 => ['g']],
+ 'H' => [1 => ['h']],
+ 'I' => [1 => ['i']],
+ 'J' => [1 => ['j']],
+ 'Nette\DI\Container' => [1 => ['container']],
+ ],
+ 'services' => [
+ 'a' => 'A',
+ 'b' => 'B',
+ 'c' => 'C',
+ 'container' => 'Nette\DI\Container',
+ 'd' => 'D',
+ 'e' => 'E',
+ 'f' => 'F',
+ 'g' => 'G',
+ 'h' => 'H',
+ 'i' => 'I',
+ 'j' => 'J',
+ ],
+ 'aliases' => [],
+ ];
+
+
+ public function __construct(array $params = [])
+ {
+ $this->parameters = $params;
+ $this->parameters += [];
+ }
+
+
+ public function createServiceA(): A
+ {
+ $service = new A;
+ return $service;
+ }
+
+
+ public function createServiceB(): B
+ {
+ $service = new B($this->createServiceA());
+ return $service;
+ }
+
+
+ public function createServiceC(): C
+ {
+ $service = new C($this->createServiceB());
+ return $service;
+ }
+
+
+ public function createServiceContainer(): Nette\DI\Container
+ {
+ return $this;
+ }
+
+
+ public function createServiceD(): D
+ {
+ $service = new D($this->createServiceC());
+ return $service;
+ }
+
+
+ public function createServiceE(): E
+ {
+ $service = new E($this->createServiceD());
+ return $service;
+ }
+
+
+ public function createServiceF(): F
+ {
+ $service = new F($this->createServiceE());
+ return $service;
+ }
+
+
+ public function createServiceG(): G
+ {
+ $service = new G($this->createServiceF());
+ return $service;
+ }
+
+
+ public function createServiceH(): H
+ {
+ $service = new H($this->createServiceG());
+ return $service;
+ }
+
+
+ public function createServiceI(): I
+ {
+ $service = new I($this->createServiceH());
+ return $service;
+ }
+
+
+ public function createServiceJ(): J
+ {
+ $service = new J($this->createServiceI());
+ return $service;
+ }
+
+
+ public function initialize()
+ {
+ }
+}
diff --git a/nette/temp/Container_dcca481015.php.lock b/nette/temp/Container_dcca481015.php.lock
new file mode 100644
index 0000000..e69de29
diff --git a/nette/temp/Container_dcca481015.php.meta b/nette/temp/Container_dcca481015.php.meta
new file mode 100644
index 0000000..1a0dca9
--- /dev/null
+++ b/nette/temp/Container_dcca481015.php.meta
@@ -0,0 +1 @@
+a:6:{i:0;i:1;i:1;a:1:{s:78:"/var/www/public/php-dependency-injection-benchmarks/nette/config/services.neon";i:1510607617;}i:2;a:3:{s:67:"/var/www/public/php-dependency-injection-benchmarks/testclasses.php";i:1510607617;s:88:"/var/www/public/php-dependency-injection-benchmarks/vendor/nette/di/src/DI/Container.php";i:1504219320;s:96:"/var/www/public/php-dependency-injection-benchmarks/vendor/nette/utils/src/Utils/SmartObject.php";i:1503250349;}i:3;a:12:{i:0;s:1:"A";i:1;s:1:"B";i:2;s:1:"C";i:3;s:1:"D";i:4;s:1:"E";i:5;s:1:"F";i:6;s:1:"G";i:7;s:1:"H";i:8;s:1:"I";i:9;s:1:"J";i:10;s:18:"Nette\DI\Container";i:11;s:17:"Nette\SmartObject";}i:4;a:10:{i:0;s:14:"B::__construct";i:1;s:14:"C::__construct";i:2;s:14:"D::__construct";i:3;s:14:"E::__construct";i:4;s:14:"F::__construct";i:5;s:14:"G::__construct";i:6;s:14:"H::__construct";i:7;s:14:"I::__construct";i:8;s:14:"J::__construct";i:9;s:31:"Nette\DI\Container::__construct";}i:5;s:32:"dc1495edc5da2ada4eb7ec24c6768928";}
\ No newline at end of file
diff --git a/nette/test1.php b/nette/test1.php
index 76b90cd..cd64cde 100644
--- a/nette/test1.php
+++ b/nette/test1.php
@@ -2,7 +2,7 @@
$t1 = microtime(true);
$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp', TRUE);
-$class = $loader->load('', function($compiler) {
+$class = $loader->load(function($compiler) {
$compiler->loadConfig(__DIR__ . '/config/services.neon');
});
$container = new $class;
@@ -12,7 +12,7 @@
for ($i = 0; $i < 10000; $i++) {
- $a = $container->createServiceA();
+ $a = $container->createService('a');
}
$t2 = microtime(true);
diff --git a/nette/test2.php b/nette/test2.php
index 8c132f8..a01408e 100644
--- a/nette/test2.php
+++ b/nette/test2.php
@@ -1,19 +1,18 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
-
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
//Trigger the autoloader
-$a = $container->createServiceA();
+$a = $container->createService('a');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
- $a = $container->createServiceA();
+ $a = $container->createService('a');
}
$t2 = microtime(true);
diff --git a/nette/test3.php b/nette/test3.php
index 4eb493e..290a539 100644
--- a/nette/test3.php
+++ b/nette/test3.php
@@ -1,21 +1,19 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
-
-//Trigger autoloader
-$j = $container->createServiceJ('j');
+$j = $container->createService('j');
unset($j);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
- $j = $container->createServiceJ();
+ $j = $container->createService('j');
}
$t2 = microtime(true);
diff --git a/nette/test4.php b/nette/test4.php
index a800cec..b681c02 100644
--- a/nette/test4.php
+++ b/nette/test4.php
@@ -1,12 +1,12 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
+
-//Trigger autoloader
$a = $container->getService('a');
unset($a);
diff --git a/nette/test5.php b/nette/test5.php
index 30e0eb1..577beff 100644
--- a/nette/test5.php
+++ b/nette/test5.php
@@ -1,21 +1,20 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
-
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
//trigger autoloader
-$a = $container->getService('b');
+$a = $container->getService('a');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
- $a = $container->getService('b');
+ $a = $container->createService('b');
}
$t2 = microtime(true);
diff --git a/nette/test6.php b/nette/test6.php
index 9d542de..aab53a2 100644
--- a/nette/test6.php
+++ b/nette/test6.php
@@ -1,15 +1,14 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
for ($i = 0; $i < $argv[1]; $i++) {
- $j = $container->createServiceJ();
+ $j = $container->createService('j');
}
$results = [
diff --git a/nette/test6a.php b/nette/test6a.php
index 171ce74..aab53a2 100644
--- a/nette/test6a.php
+++ b/nette/test6a.php
@@ -1,19 +1,14 @@
setTempDirectory(__DIR__ . '/temp');
-$configurator->defaultExtensions = array();
-$configurator->addConfig(__DIR__ . '/config/services.neon');
-$container = $configurator->createContainer(); // compile
+$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp');
+$class = $loader->load(function($compiler) {
+ $compiler->loadConfig(__DIR__ . '/config/services.neon');
+});
+$container = new $class;
for ($i = 0; $i < $argv[1]; $i++) {
- $j = $container->createServiceJ();
+ $j = $container->createService('j');
}
$results = [
diff --git a/php-di/test6a.php b/php-di/test6a.php
new file mode 100644
index 0000000..0ee6466
--- /dev/null
+++ b/php-di/test6a.php
@@ -0,0 +1,27 @@
+addDefinitions(__DIR__ . '/config-test3.php');
+$builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache());
+
+$container = $builder->build();
+
+//trigger autoloader
+$j = $container->get('J');
+unset ($j);
+
+$t1 = microtime(true);
+
+for ($i = 0; $i < 10000; $i++) {
+ $j = $container->get('J');
+
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/slince-di/test1.php b/slince-di/test1.php
new file mode 100644
index 0000000..a497adf
--- /dev/null
+++ b/slince-di/test1.php
@@ -0,0 +1,18 @@
+get('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/slince-di/test2.php b/slince-di/test2.php
new file mode 100644
index 0000000..3639d9f
--- /dev/null
+++ b/slince-di/test2.php
@@ -0,0 +1,20 @@
+get('A');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/slince-di/test3.php b/slince-di/test3.php
new file mode 100644
index 0000000..36b9a22
--- /dev/null
+++ b/slince-di/test3.php
@@ -0,0 +1,19 @@
+get('J');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('J');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/slince-di/test4.php b/slince-di/test4.php
new file mode 100644
index 0000000..583575d
--- /dev/null
+++ b/slince-di/test4.php
@@ -0,0 +1,17 @@
+get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/slince-di/test5.php b/slince-di/test5.php
new file mode 100644
index 0000000..0057453
--- /dev/null
+++ b/slince-di/test5.php
@@ -0,0 +1,20 @@
+define('A', 'A');
+$di->share('A');
+$b = $di->get('B');
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di->get('B');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/slince-di/test6.php b/slince-di/test6.php
new file mode 100644
index 0000000..aea8378
--- /dev/null
+++ b/slince-di/test6.php
@@ -0,0 +1,16 @@
+get('J');
+}
+
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/slince-di/test6a.php b/slince-di/test6a.php
new file mode 100644
index 0000000..203558a
--- /dev/null
+++ b/slince-di/test6a.php
@@ -0,0 +1,15 @@
+get('J');
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/symfonydi/container_test1.php b/symfonydi/container_test1.php
index b1ab7e8..f0a987d 100644
--- a/symfonydi/container_test1.php
+++ b/symfonydi/container_test1.php
@@ -1,36 +1,32 @@
services =
- $this->scopedServices =
- $this->scopeStacks = array();
- $this->scopes = array();
- $this->scopeChildren = array();
+ $this->services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ );
$this->methodMap = array(
- 'a' => 'getAService',
+ 'A' => 'getAService',
);
$this->aliases = array();
@@ -41,13 +37,31 @@ public function __construct()
*/
public function compile()
{
- throw new LogicException('You cannot compile a dumped frozen container.');
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
}
/**
- * Gets the 'a' service.
+ * Gets the public 'A' service.
*
- * @return \A A A instance.
+ * @return \A
*/
protected function getAService()
{
diff --git a/symfonydi/container_test2.php b/symfonydi/container_test2.php
new file mode 100644
index 0000000..f0a987d
--- /dev/null
+++ b/symfonydi/container_test2.php
@@ -0,0 +1,70 @@
+services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ );
+ $this->methodMap = array(
+ 'A' => 'getAService',
+ );
+
+ $this->aliases = array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function compile()
+ {
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
+ }
+
+ /**
+ * Gets the public 'A' service.
+ *
+ * @return \A
+ */
+ protected function getAService()
+ {
+ return new \A();
+ }
+}
diff --git a/symfonydi/container_test3.php b/symfonydi/container_test3.php
new file mode 100644
index 0000000..9912868
--- /dev/null
+++ b/symfonydi/container_test3.php
@@ -0,0 +1,178 @@
+services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ 'b' => 'B',
+ 'c' => 'C',
+ 'd' => 'D',
+ 'e' => 'E',
+ 'f' => 'F',
+ 'g' => 'G',
+ 'h' => 'H',
+ 'i' => 'I',
+ 'j' => 'J',
+ );
+ $this->methodMap = array(
+ 'A' => 'getAService',
+ 'B' => 'getBService',
+ 'C' => 'getCService',
+ 'D' => 'getDService',
+ 'E' => 'getEService',
+ 'F' => 'getFService',
+ 'G' => 'getGService',
+ 'H' => 'getHService',
+ 'I' => 'getIService',
+ 'J' => 'getJService',
+ );
+
+ $this->aliases = array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function compile()
+ {
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
+ }
+
+ /**
+ * Gets the public 'A' service.
+ *
+ * @return \A
+ */
+ protected function getAService()
+ {
+ return new \A();
+ }
+
+ /**
+ * Gets the public 'B' service.
+ *
+ * @return \B
+ */
+ protected function getBService()
+ {
+ return new \B(new \A());
+ }
+
+ /**
+ * Gets the public 'C' service.
+ *
+ * @return \C
+ */
+ protected function getCService()
+ {
+ return new \C(new \B(new \A()));
+ }
+
+ /**
+ * Gets the public 'D' service.
+ *
+ * @return \D
+ */
+ protected function getDService()
+ {
+ return new \D(new \C(new \B(new \A())));
+ }
+
+ /**
+ * Gets the public 'E' service.
+ *
+ * @return \E
+ */
+ protected function getEService()
+ {
+ return new \E(new \D(new \C(new \B(new \A()))));
+ }
+
+ /**
+ * Gets the public 'F' service.
+ *
+ * @return \F
+ */
+ protected function getFService()
+ {
+ return new \F(new \E(new \D(new \C(new \B(new \A())))));
+ }
+
+ /**
+ * Gets the public 'G' service.
+ *
+ * @return \G
+ */
+ protected function getGService()
+ {
+ return new \G(new \F(new \E(new \D(new \C(new \B(new \A()))))));
+ }
+
+ /**
+ * Gets the public 'H' service.
+ *
+ * @return \H
+ */
+ protected function getHService()
+ {
+ return new \H(new \G(new \F(new \E(new \D(new \C(new \B(new \A())))))));
+ }
+
+ /**
+ * Gets the public 'I' service.
+ *
+ * @return \I
+ */
+ protected function getIService()
+ {
+ return new \I(new \H(new \G(new \F(new \E(new \D(new \C(new \B(new \A()))))))));
+ }
+
+ /**
+ * Gets the public 'J' service.
+ *
+ * @return \J
+ */
+ protected function getJService()
+ {
+ return new \J(new \I(new \H(new \G(new \F(new \E(new \D(new \C(new \B(new \A())))))))));
+ }
+}
diff --git a/symfonydi/container_test4.php b/symfonydi/container_test4.php
index 59f5fae..857d7a6 100644
--- a/symfonydi/container_test4.php
+++ b/symfonydi/container_test4.php
@@ -1,36 +1,32 @@
services =
- $this->scopedServices =
- $this->scopeStacks = array();
- $this->scopes = array();
- $this->scopeChildren = array();
+ $this->services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ );
$this->methodMap = array(
- 'a' => 'getAService',
+ 'A' => 'getAService',
);
$this->aliases = array();
@@ -41,19 +37,34 @@ public function __construct()
*/
public function compile()
{
- throw new LogicException('You cannot compile a dumped frozen container.');
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
}
/**
- * Gets the 'a' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
+ }
+
+ /**
+ * Gets the public 'A' shared service.
*
- * @return \A A A instance.
+ * @return \A
*/
protected function getAService()
{
- return $this->services['a'] = new \A();
+ return $this->services['A'] = new \A();
}
}
diff --git a/symfonydi/container_test5.php b/symfonydi/container_test5.php
index 972aa1f..40df73e 100644
--- a/symfonydi/container_test5.php
+++ b/symfonydi/container_test5.php
@@ -1,37 +1,34 @@
services =
- $this->scopedServices =
- $this->scopeStacks = array();
- $this->scopes = array();
- $this->scopeChildren = array();
+ $this->services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ 'b' => 'B',
+ );
$this->methodMap = array(
- 'a' => 'getAService',
- 'b' => 'getBService',
+ 'A' => 'getAService',
+ 'B' => 'getBService',
);
$this->aliases = array();
@@ -42,29 +39,44 @@ public function __construct()
*/
public function compile()
{
- throw new LogicException('You cannot compile a dumped frozen container.');
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
}
/**
- * Gets the 'a' service.
- *
- * This service is shared.
- * This method always returns the same instance of the service.
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
+ }
+
+ /**
+ * Gets the public 'A' shared service.
*
- * @return \A A A instance.
+ * @return \A
*/
protected function getAService()
{
- return $this->services['a'] = new \A();
+ return $this->services['A'] = new \A();
}
/**
- * Gets the 'b' service.
+ * Gets the public 'B' service.
*
- * @return \B A B instance.
+ * @return \B
*/
protected function getBService()
{
- return new \B($this->get('a'));
+ return new \B(${($_ = isset($this->services['A']) ? $this->services['A'] : $this->get('A')) && false ?: '_'});
}
}
diff --git a/symfonydi/container_test6.php b/symfonydi/container_test6.php
index a6796bb..9912868 100644
--- a/symfonydi/container_test6.php
+++ b/symfonydi/container_test6.php
@@ -1,45 +1,50 @@
services =
- $this->scopedServices =
- $this->scopeStacks = array();
- $this->scopes = array();
- $this->scopeChildren = array();
+ $this->services = array();
+ $this->normalizedIds = array(
+ 'a' => 'A',
+ 'b' => 'B',
+ 'c' => 'C',
+ 'd' => 'D',
+ 'e' => 'E',
+ 'f' => 'F',
+ 'g' => 'G',
+ 'h' => 'H',
+ 'i' => 'I',
+ 'j' => 'J',
+ );
$this->methodMap = array(
- 'a' => 'getAService',
- 'b' => 'getBService',
- 'c' => 'getCService',
- 'd' => 'getDService',
- 'e' => 'getEService',
- 'f' => 'getFService',
- 'g' => 'getGService',
- 'h' => 'getHService',
- 'i' => 'getIService',
- 'j' => 'getJService',
+ 'A' => 'getAService',
+ 'B' => 'getBService',
+ 'C' => 'getCService',
+ 'D' => 'getDService',
+ 'E' => 'getEService',
+ 'F' => 'getFService',
+ 'G' => 'getGService',
+ 'H' => 'getHService',
+ 'I' => 'getIService',
+ 'J' => 'getJService',
);
$this->aliases = array();
@@ -50,13 +55,31 @@ public function __construct()
*/
public function compile()
{
- throw new LogicException('You cannot compile a dumped frozen container.');
+ throw new LogicException('You cannot compile a dumped container that was already compiled.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isCompiled()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrozen()
+ {
+ @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
+
+ return true;
}
/**
- * Gets the 'a' service.
+ * Gets the public 'A' service.
*
- * @return \A A A instance.
+ * @return \A
*/
protected function getAService()
{
@@ -64,9 +87,9 @@ protected function getAService()
}
/**
- * Gets the 'b' service.
+ * Gets the public 'B' service.
*
- * @return \B A B instance.
+ * @return \B
*/
protected function getBService()
{
@@ -74,9 +97,9 @@ protected function getBService()
}
/**
- * Gets the 'c' service.
+ * Gets the public 'C' service.
*
- * @return \C A C instance.
+ * @return \C
*/
protected function getCService()
{
@@ -84,9 +107,9 @@ protected function getCService()
}
/**
- * Gets the 'd' service.
+ * Gets the public 'D' service.
*
- * @return \D A D instance.
+ * @return \D
*/
protected function getDService()
{
@@ -94,9 +117,9 @@ protected function getDService()
}
/**
- * Gets the 'e' service.
+ * Gets the public 'E' service.
*
- * @return \E A E instance.
+ * @return \E
*/
protected function getEService()
{
@@ -104,9 +127,9 @@ protected function getEService()
}
/**
- * Gets the 'f' service.
+ * Gets the public 'F' service.
*
- * @return \F A F instance.
+ * @return \F
*/
protected function getFService()
{
@@ -114,9 +137,9 @@ protected function getFService()
}
/**
- * Gets the 'g' service.
+ * Gets the public 'G' service.
*
- * @return \G A G instance.
+ * @return \G
*/
protected function getGService()
{
@@ -124,9 +147,9 @@ protected function getGService()
}
/**
- * Gets the 'h' service.
+ * Gets the public 'H' service.
*
- * @return \H A H instance.
+ * @return \H
*/
protected function getHService()
{
@@ -134,9 +157,9 @@ protected function getHService()
}
/**
- * Gets the 'i' service.
+ * Gets the public 'I' service.
*
- * @return \I A I instance.
+ * @return \I
*/
protected function getIService()
{
@@ -144,9 +167,9 @@ protected function getIService()
}
/**
- * Gets the 'j' service.
+ * Gets the public 'J' service.
*
- * @return \J A J instance.
+ * @return \J
*/
protected function getJService()
{
diff --git a/symfonydi/test1.php b/symfonydi/test1.php
index 6c43b4f..6dafbde 100644
--- a/symfonydi/test1.php
+++ b/symfonydi/test1.php
@@ -12,7 +12,7 @@
$definition = new Symfony\Component\DependencyInjection\Definition('A', []);
- $definition->setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition('A', $definition);
$container->compile();
diff --git a/symfonydi/test2.php b/symfonydi/test2.php
index 4251067..3d1af12 100644
--- a/symfonydi/test2.php
+++ b/symfonydi/test2.php
@@ -1,6 +1,6 @@
setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition('A', $definition);
$container->compile();
diff --git a/symfonydi/test3.php b/symfonydi/test3.php
index df9a18c..ba212e6 100644
--- a/symfonydi/test3.php
+++ b/symfonydi/test3.php
@@ -1,6 +1,6 @@
setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition($classes[$i], $definition);
}
diff --git a/symfonydi/test5.php b/symfonydi/test5.php
index ee80336..cb4aa22 100644
--- a/symfonydi/test5.php
+++ b/symfonydi/test5.php
@@ -9,10 +9,11 @@
$container = new Symfony\Component\DependencyInjection\ContainerBuilder;
- $container->register('A', 'A');
+ $definition = new Symfony\Component\DependencyInjection\Definition('A', []);
+ $container->setDefinition('A', $definition);
$ref = [new Symfony\Component\DependencyInjection\Reference('A')];
$definition = new Symfony\Component\DependencyInjection\Definition('B', $ref );
- $definition->setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition('B', $definition);
diff --git a/symfonydi/test6.php b/symfonydi/test6.php
index cfa0116..5992444 100644
--- a/symfonydi/test6.php
+++ b/symfonydi/test6.php
@@ -18,7 +18,7 @@
else $ref = [];
$definition = new Symfony\Component\DependencyInjection\Definition($classes[$i], $ref );
- $definition->setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition($classes[$i], $definition);
}
diff --git a/symfonydi/test6a.php b/symfonydi/test6a.php
index 998dbe5..6b912ab 100644
--- a/symfonydi/test6a.php
+++ b/symfonydi/test6a.php
@@ -17,7 +17,7 @@
else $ref = [];
$definition = new Symfony\Component\DependencyInjection\Definition($classes[$i], $ref );
- $definition->setScope('prototype');
+ $definition->setShared(false);
$container->setDefinition($classes[$i], $definition);
}
diff --git a/test1-5_results.html b/test1-5_results.html
index 7b824f8..c0138ee 100644
--- a/test1-5_results.html
+++ b/test1-5_results.html
@@ -1 +1 @@
-
Test 1 - Create single object (incl autoload time)
Container | Time | Memory | Files |
---|
dice | 0.0256 | 0.4305 | 12 |
phalcon | 0.0578 | 0.2629 | 2 |
symfonydi | 0.0719 | 0.4868 | 15 |
njasm | 0.0811 | 0.4374 | 19 |
pimple | 0.0874 | 0.4187 | 12 |
league | 0.1155 | 0.4821 | 22 |
auryn | 0.1854 | 0.5446 | 17 |
aura | 0.2104 | 0.4716 | 18 |
laravel | 0.2396 | 0.5499 | 13 |
zend-servicemanager | 0.2797 | 0.625 | 16 |
php-di | 0.3723 | 0.5937 | 43 |
zend-di | 0.6748 | 0.7486 | 35 |
Test 2 - Create single object (excl autoload time)
Container | Time | Memory | Files |
---|
dice | 0.025 | 0.4304 | 12 |
phalcon | 0.0584 | 0.2629 | 2 |
symfonydi | 0.0679 | 0.4868 | 15 |
njasm | 0.0806 | 0.4366 | 19 |
pimple | 0.0875 | 0.4189 | 12 |
league | 0.113 | 0.4819 | 22 |
auryn | 0.1829 | 0.5447 | 17 |
aura | 0.2091 | 0.4713 | 18 |
laravel | 0.2382 | 0.5499 | 13 |
zend-servicemanager | 0.2821 | 0.6249 | 16 |
php-di | 0.3606 | 0.5947 | 43 |
zend-di | 0.6456 | 0.7479 | 35 |
Test 3 - Create deep object graph
Container | Time | Memory | Files |
---|
symfonydi | 0.1537 | 0.4908 | 15 |
dice | 0.5377 | 0.4304 | 12 |
phalcon | 0.6986 | 0.2957 | 2 |
pimple | 0.8953 | 0.4235 | 12 |
njasm | 1.4954 | 0.437 | 19 |
league | 1.5364 | 0.4819 | 22 |
aura | 2.3438 | 0.4718 | 18 |
zend-servicemanager | 2.6888 | 0.6292 | 16 |
auryn | 3.1195 | 0.5447 | 17 |
laravel | 3.2513 | 0.5503 | 13 |
php-di | 4.9863 | 0.6096 | 47 |
zend-di | 22.6618 | 0.7482 | 36 |
Test 4 - Fetch the same instance (service) from the container repeatedly
Container | Time | Memory | Files |
---|
phalcon | 0.0083 | 0.2629 | 2 |
pimple | 0.0114 | 0.4185 | 12 |
dice | 0.0118 | 0.4306 | 12 |
njasm | 0.0125 | 0.4366 | 19 |
aura | 0.0166 | 0.4714 | 18 |
laravel | 0.0196 | 0.5501 | 13 |
php-di | 0.0207 | 0.5634 | 38 |
league | 0.0269 | 0.4819 | 22 |
zend-servicemanager | 0.034 | 0.6249 | 16 |
symfonydi | 0.0408 | 0.4868 | 15 |
auryn | 0.0559 | 0.5448 | 17 |
zend-di | 0.1964 | 0.7482 | 35 |
Test 5 - Inject a service into a new object repeatedly
Container | Time | Memory | Files |
---|
dice | 0.0717 | 0.4306 | 12 |
phalcon | 0.0799 | 0.2657 | 2 |
symfonydi | 0.0955 | 0.4877 | 15 |
pimple | 0.107 | 0.4195 | 12 |
njasm | 0.1751 | 0.4366 | 19 |
league | 0.1948 | 0.4822 | 22 |
aura | 0.2347 | 0.4719 | 18 |
zend-servicemanager | 0.3238 | 0.6252 | 16 |
laravel | 0.3895 | 0.5501 | 13 |
auryn | 0.4098 | 0.5448 | 17 |
php-di | 0.586 | 0.6076 | 47 |
zend-di | 1.5092 | 0.7488 | 36 |
\ No newline at end of file
+Test 1 - Create single object (incl autoload time)
Container | Time | Memory | Files |
---|
dice | 0.0093 | 0.5353 | 10 |
joomla-di | 0.0133 | 0.5353 | 10 |
phalcon | 0.0166 | 0.5353 | 9 |
di52 | 0.0176 | 0.5613 | 10 |
pimple | 0.0223 | 0.5353 | 10 |
DiMaria | 0.028 | 0.5353 | 12 |
symfonydi | 0.0294 | 0.5589 | 14 |
yii2-di | 0.0302 | 0.5537 | 13 |
chernozem | 0.0345 | 0.5353 | 13 |
unbox | 0.036 | 0.5353 | 16 |
nette | 0.0491 | 0.5449 | 14 |
zend-servicemanager | 0.0559 | 0.5814 | 16 |
auryn | 0.0569 | 0.582 | 15 |
laravel | 0.0577 | 0.5859 | 12 |
njasm | 0.0584 | 0.5694 | 18 |
slince-di | 0.0656 | 0.5691 | 17 |
aura | 0.0676 | 0.5633 | 19 |
league | 0.1008 | 0.5706 | 30 |
php-di | 0.2264 | 0.6725 | 44 |
zend-di | 0.2278 | 0.7128 | 34 |
Test 2 - Create single object (excl autoload time)
Container | Time | Memory | Files |
---|
dice | 0.0034 | 0.5353 | 10 |
league | 0.0044 | 0.5706 | 30 |
joomla-di | 0.0059 | 0.5353 | 10 |
di52 | 0.0066 | 0.5613 | 10 |
symfonydi | 0.0069 | 0.5589 | 14 |
DiMaria | 0.0075 | 0.5353 | 12 |
unbox | 0.0076 | 0.5353 | 16 |
yii2-di | 0.0077 | 0.5538 | 13 |
njasm | 0.01 | 0.5694 | 18 |
chernozem | 0.0104 | 0.5353 | 13 |
pimple | 0.0136 | 0.5353 | 10 |
zend-servicemanager | 0.0157 | 0.5814 | 16 |
aura | 0.0163 | 0.5633 | 19 |
phalcon | 0.0165 | 0.5353 | 9 |
nette | 0.0203 | 0.5449 | 13 |
slince-di | 0.0222 | 0.5692 | 17 |
auryn | 0.0277 | 0.582 | 15 |
laravel | 0.0375 | 0.5859 | 12 |
php-di | 0.0413 | 0.6726 | 44 |
zend-di | 0.0968 | 0.7128 | 34 |
Test 3 - Create deep object graph
Container | Time | Memory | Files |
---|
joomla-di | 0.0081 | 0.5353 | 10 |
symfonydi | 0.0209 | 0.5592 | 14 |
unbox | 0.0331 | 0.5353 | 16 |
nette | 0.0422 | 0.5449 | 13 |
dice | 0.0909 | 0.5353 | 10 |
yii2-di | 0.1082 | 0.5802 | 14 |
chernozem | 0.1129 | 0.5353 | 13 |
DiMaria | 0.1339 | 0.5353 | 12 |
pimple | 0.151 | 0.5353 | 10 |
phalcon | 0.1892 | 0.5353 | 9 |
aura | 0.2023 | 0.5635 | 19 |
njasm | 0.2255 | 0.5698 | 18 |
di52 | 0.3471 | 4.8994 | 10 |
slince-di | 0.465 | 0.5692 | 17 |
zend-servicemanager | 0.4676 | 0.5816 | 16 |
auryn | 0.52 | 0.582 | 15 |
laravel | 0.5793 | 0.5859 | 12 |
php-di | 0.696 | 0.6763 | 49 |
league | 1.8751 | 0.6861 | 32 |
zend-di | 4.4777 | 0.7132 | 35 |
Test 4 - Fetch the same instance (service) from the container repeatedly
Container | Time | Memory | Files |
---|
nette | 0.0004 | 0.5449 | 13 |
di52 | 0.0008 | 0.5613 | 10 |
njasm | 0.0008 | 0.5694 | 18 |
aura | 0.0009 | 0.5633 | 19 |
zend-servicemanager | 0.001 | 0.5814 | 16 |
DiMaria | 0.0011 | 0.5353 | 12 |
dice | 0.0013 | 0.5353 | 10 |
phalcon | 0.0016 | 0.5353 | 9 |
pimple | 0.0019 | 0.5353 | 10 |
php-di | 0.0019 | 0.6402 | 39 |
joomla-di | 0.0027 | 0.5353 | 10 |
symfonydi | 0.0028 | 0.5589 | 14 |
league | 0.0045 | 0.5701 | 31 |
unbox | 0.0047 | 0.5353 | 16 |
auryn | 0.0066 | 0.5821 | 15 |
laravel | 0.0066 | 0.5859 | 12 |
chernozem | 0.0073 | 0.5353 | 13 |
yii2-di | 0.0083 | 0.5537 | 13 |
zend-di | 0.0284 | 0.7128 | 34 |
slince-di | 0.0307 | 0.5691 | 17 |
Test 5 - Inject a service into a new object repeatedly
Container | Time | Memory | Files |
---|
joomla-di | 0.0083 | 0.5353 | 10 |
symfonydi | 0.0095 | 0.5589 | 14 |
dice | 0.0111 | 0.5353 | 10 |
DiMaria | 0.0177 | 0.5353 | 12 |
yii2-di | 0.0177 | 0.5816 | 14 |
pimple | 0.0183 | 0.5353 | 10 |
chernozem | 0.0195 | 0.5353 | 13 |
nette | 0.0246 | 0.5449 | 13 |
phalcon | 0.0247 | 0.5353 | 9 |
njasm | 0.0282 | 0.5694 | 18 |
di52 | 0.0327 | 0.8585 | 10 |
unbox | 0.0384 | 0.5353 | 16 |
aura | 0.0391 | 0.5633 | 19 |
slince-di | 0.054 | 0.5693 | 17 |
zend-servicemanager | 0.0543 | 0.5814 | 16 |
auryn | 0.0695 | 0.5821 | 15 |
laravel | 0.0765 | 0.5859 | 12 |
php-di | 0.083 | 0.6747 | 49 |
league | 0.0992 | 0.5701 | 36 |
zend-di | 0.2416 | 0.7132 | 35 |
\ No newline at end of file
diff --git a/test1-5_runner.php b/test1-5_runner.php
index 8380662..eafd00a 100644
--- a/test1-5_runner.php
+++ b/test1-5_runner.php
@@ -21,7 +21,7 @@ function cliPrint($text, $newLine = true) {
cliPrint('Running each test ' . $runs . ' times');
//Containers to be tested (dir names)
-$containers = ['aura', 'auryn', 'dice', 'laravel', 'league', 'njasm', 'phalcon', 'php-di', 'pimple', 'symfonydi', 'zend-di', 'zend-servicemanager'];
+$containers = ['aura', 'auryn', 'chernozem', 'di52', 'dice', 'DiMaria', 'joomla-di', 'laravel', 'league', 'nette', 'njasm', 'phalcon', 'php-di', 'pimple', 'slince-di', 'symfonydi', 'unbox', 'yii2-di', 'zend-di', 'zend-servicemanager'];
//Default ini file to use for tests
diff --git a/test6_runner.php b/test6_runner.php
index 201356c..7c28af6 100644
--- a/test6_runner.php
+++ b/test6_runner.php
@@ -1,4 +1,5 @@
';
}
-
+$ta2 = microtime(true);
+echo $ta2 - $ta1;
if (!$isCli) echo $html;
else file_put_contents('test6_results.html', $html);
\ No newline at end of file
diff --git a/unbox/test1.php b/unbox/test1.php
new file mode 100644
index 0000000..b132e4d
--- /dev/null
+++ b/unbox/test1.php
@@ -0,0 +1,22 @@
+register("A");
+
+$di = $factory->createContainer();
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->get('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/unbox/test2.php b/unbox/test2.php
new file mode 100644
index 0000000..5a74e64
--- /dev/null
+++ b/unbox/test2.php
@@ -0,0 +1,23 @@
+register("A");
+
+$di = $factory->createContainer();
+$a = $di->get('A');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->create('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/unbox/test3.php b/unbox/test3.php
new file mode 100644
index 0000000..82ee4d4
--- /dev/null
+++ b/unbox/test3.php
@@ -0,0 +1,33 @@
+register("A");
+$factory->register("B");
+$factory->register("C");
+$factory->register("D");
+$factory->register("E");
+$factory->register("F");
+$factory->register("G");
+$factory->register("H");
+$factory->register("I");
+$factory->register("J");
+
+$di = $factory->createContainer();
+$a = $di->get('J');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->create('J');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/unbox/test4.php b/unbox/test4.php
new file mode 100644
index 0000000..38e453e
--- /dev/null
+++ b/unbox/test4.php
@@ -0,0 +1,22 @@
+register("A");
+
+$di = $factory->createContainer();
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/unbox/test5.php b/unbox/test5.php
new file mode 100644
index 0000000..b26d494
--- /dev/null
+++ b/unbox/test5.php
@@ -0,0 +1,23 @@
+register("A");
+$factory->register("B");
+
+$di = $factory->createContainer();
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di->create('B');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/unbox/test6.php b/unbox/test6.php
new file mode 100644
index 0000000..00830c7
--- /dev/null
+++ b/unbox/test6.php
@@ -0,0 +1,28 @@
+register("A");
+$factory->register("B");
+$factory->register("C");
+$factory->register("D");
+$factory->register("E");
+$factory->register("F");
+$factory->register("G");
+$factory->register("H");
+$factory->register("I");
+$factory->register("J");
+$di = $factory->createContainer();
+
+for ($i = 0; $i < $argv[1]; $i++) {
+ $j = $di->create('J');
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/unbox/test6a.php b/unbox/test6a.php
new file mode 100644
index 0000000..8c07d33
--- /dev/null
+++ b/unbox/test6a.php
@@ -0,0 +1,28 @@
+register("A");
+$factory->register("B");
+$factory->register("C");
+$factory->register("D");
+$factory->register("E");
+$factory->register("F");
+$factory->register("G");
+$factory->register("H");
+$factory->register("I");
+$factory->register("J");
+
+$di = $factory->createContainer();
+for ($i = 0; $i < $argv[1]; $i++) {
+ $j = $di->create('J');
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/yii2-di/test1.php b/yii2-di/test1.php
new file mode 100644
index 0000000..c6b63ee
--- /dev/null
+++ b/yii2-di/test1.php
@@ -0,0 +1,19 @@
+get('A');
+}
+
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/yii2-di/test2.php b/yii2-di/test2.php
new file mode 100644
index 0000000..db9f180
--- /dev/null
+++ b/yii2-di/test2.php
@@ -0,0 +1,20 @@
+get('A');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $a = $di->get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/yii2-di/test3.php b/yii2-di/test3.php
new file mode 100644
index 0000000..3807ea0
--- /dev/null
+++ b/yii2-di/test3.php
@@ -0,0 +1,20 @@
+get('J');
+unset ($a);
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('J');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/yii2-di/test4.php b/yii2-di/test4.php
new file mode 100644
index 0000000..3a7bb15
--- /dev/null
+++ b/yii2-di/test4.php
@@ -0,0 +1,18 @@
+setSingleton('A');
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $j = $di->get('A');
+}
+$t2 = microtime(true);
+
+$results = [
+ 'time' => $t2 - $t1,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/yii2-di/test5.php b/yii2-di/test5.php
new file mode 100644
index 0000000..c3927db
--- /dev/null
+++ b/yii2-di/test5.php
@@ -0,0 +1,19 @@
+setSingleton('A');
+
+$t1 = microtime(true);
+for ($i = 0; $i < 10000; $i++) {
+ $b = $di->get('B');
+}
+$t2 = microtime(true);
+
+$results = [
+'time' => $t2 - $t1,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file
diff --git a/yii2-di/test6.php b/yii2-di/test6.php
new file mode 100644
index 0000000..7143096
--- /dev/null
+++ b/yii2-di/test6.php
@@ -0,0 +1,17 @@
+get('J');
+}
+
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/yii2-di/test6a.php b/yii2-di/test6a.php
new file mode 100644
index 0000000..f4ef932
--- /dev/null
+++ b/yii2-di/test6a.php
@@ -0,0 +1,15 @@
+get('J');
+}
+
+$results = [
+'time' => 0,
+'files' => count(get_included_files()),
+'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
diff --git a/zend-servicemanager/test1.php b/zend-servicemanager/test1.php
index 4a4fca2..5f25538 100644
--- a/zend-servicemanager/test1.php
+++ b/zend-servicemanager/test1.php
@@ -1,22 +1,13 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', false);
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
-
-
-
-
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', false);
for ($i = 0; $i < 10000; $i++) {
$a = $serviceManager->get('A');
diff --git a/zend-servicemanager/test2.php b/zend-servicemanager/test2.php
index b1c3964..4a46a92 100644
--- a/zend-servicemanager/test2.php
+++ b/zend-servicemanager/test2.php
@@ -1,18 +1,12 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', false);
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
-
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', false);
//trigger autoloaders
$a = $serviceManager->get('A');
diff --git a/zend-servicemanager/test3.php b/zend-servicemanager/test3.php
index 4d4af05..f5604a5 100644
--- a/zend-servicemanager/test3.php
+++ b/zend-servicemanager/test3.php
@@ -1,74 +1,30 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', false);
-
-
- $serviceManager->setFactory('B', function($serviceManager) {
- return new B($serviceManager->get('A'));
- });
- $serviceManager->setShared('B', false);
-
- $serviceManager->setFactory('C', function($serviceManager) {
- return new C($serviceManager->get('B'));
- });
-
- $serviceManager->setShared('C', false);
-
- $serviceManager->setFactory('D', function($serviceManager) {
- return new D($serviceManager->get('C'));
- });
-
- $serviceManager->setShared('D', false);
-
- $serviceManager->setFactory('E', function($serviceManager) {
- return new E($serviceManager->get('D'));
- });
-
- $serviceManager->setShared('E', false);
-
- $serviceManager->setFactory('F', function($serviceManager) {
- return new F($serviceManager->get('E'));
- });
-
- $serviceManager->setShared('F', false);
-
- $serviceManager->setFactory('G', function($serviceManager) {
- return new G($serviceManager->get('F'));
- });
-
- $serviceManager->setShared('G', false);
-
- $serviceManager->setFactory('H', function($serviceManager) {
- return new H($serviceManager->get('G'));
- });
-
- $serviceManager->setShared('H', false);
-
- $serviceManager->setFactory('I', function($serviceManager) {
- return new I($serviceManager->get('H'));
- });
-
- $serviceManager->setShared('I', false);
-
- $serviceManager->setFactory('J', function($serviceManager) {
- return new J($serviceManager->get('I'));
- });
-
- $serviceManager->setShared('J', false);
-
-
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
-
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ 'B' => ReflectionBasedAbstractFactory::class,
+ 'C' => ReflectionBasedAbstractFactory::class,
+ 'D' => ReflectionBasedAbstractFactory::class,
+ 'E' => ReflectionBasedAbstractFactory::class,
+ 'F' => ReflectionBasedAbstractFactory::class,
+ 'G' => ReflectionBasedAbstractFactory::class,
+ 'H' => ReflectionBasedAbstractFactory::class,
+ 'I' => ReflectionBasedAbstractFactory::class,
+ 'J' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', false);
+$serviceManager->setShared('B', false);
+$serviceManager->setShared('C', false);
+$serviceManager->setShared('D', false);
+$serviceManager->setShared('E', false);
+$serviceManager->setShared('F', false);
+$serviceManager->setShared('G', false);
+$serviceManager->setShared('H', false);
+$serviceManager->setShared('I', false);
+$serviceManager->setShared('J', false);
//trigger autoloaders
$j = $serviceManager->get('J');
diff --git a/zend-servicemanager/test4.php b/zend-servicemanager/test4.php
index 58fea48..a0adb84 100644
--- a/zend-servicemanager/test4.php
+++ b/zend-servicemanager/test4.php
@@ -1,18 +1,12 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', true);
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
-
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', true);
//trigger autoloaders
$a = $serviceManager->get('A');
diff --git a/zend-servicemanager/test5.php b/zend-servicemanager/test5.php
index ece9c01..ddb5eff 100644
--- a/zend-servicemanager/test5.php
+++ b/zend-servicemanager/test5.php
@@ -1,27 +1,14 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', true);
-
-
- $serviceManager->setFactory('B', function($serviceManager) {
- return new B($serviceManager->get('A'));
- });
- $serviceManager->setShared('B', false);
-
-
-
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
-
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ 'B' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', true);
+$serviceManager->setShared('B', false);
//trigger autoloaders
$j = $serviceManager->get('B');
diff --git a/zend-servicemanager/test6.php b/zend-servicemanager/test6.php
index 0db75cb..96f2e4c 100644
--- a/zend-servicemanager/test6.php
+++ b/zend-servicemanager/test6.php
@@ -1,73 +1,30 @@
setFactory('A', function() {
- return new A;
- });
- $serviceManager->setShared('A', false);
-
-
- $serviceManager->setFactory('B', function($serviceManager) {
- return new B($serviceManager->get('A'));
- });
- $serviceManager->setShared('B', false);
-
- $serviceManager->setFactory('C', function($serviceManager) {
- return new C($serviceManager->get('B'));
- });
-
- $serviceManager->setShared('C', false);
-
- $serviceManager->setFactory('D', function($serviceManager) {
- return new D($serviceManager->get('C'));
- });
-
- $serviceManager->setShared('D', false);
-
- $serviceManager->setFactory('E', function($serviceManager) {
- return new E($serviceManager->get('D'));
- });
-
- $serviceManager->setShared('E', false);
-
- $serviceManager->setFactory('F', function($serviceManager) {
- return new F($serviceManager->get('E'));
- });
-
- $serviceManager->setShared('F', false);
-
- $serviceManager->setFactory('G', function($serviceManager) {
- return new G($serviceManager->get('F'));
- });
-
- $serviceManager->setShared('G', false);
-
- $serviceManager->setFactory('H', function($serviceManager) {
- return new H($serviceManager->get('G'));
- });
-
- $serviceManager->setShared('H', false);
-
- $serviceManager->setFactory('I', function($serviceManager) {
- return new I($serviceManager->get('H'));
- });
-
- $serviceManager->setShared('I', false);
-
- $serviceManager->setFactory('J', function($serviceManager) {
- return new J($serviceManager->get('I'));
- });
-
- $serviceManager->setShared('J', false);
-
-
- }
-}
-
-
-$config = new ServiceConfiguration();
-$serviceManager = new \Zend\ServiceManager\ServiceManager($config);
+use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
+$serviceManager = new \Zend\ServiceManager\ServiceManager([
+ 'factories' => [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ 'B' => ReflectionBasedAbstractFactory::class,
+ 'C' => ReflectionBasedAbstractFactory::class,
+ 'D' => ReflectionBasedAbstractFactory::class,
+ 'E' => ReflectionBasedAbstractFactory::class,
+ 'F' => ReflectionBasedAbstractFactory::class,
+ 'G' => ReflectionBasedAbstractFactory::class,
+ 'H' => ReflectionBasedAbstractFactory::class,
+ 'I' => ReflectionBasedAbstractFactory::class,
+ 'J' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', false);
+$serviceManager->setShared('B', false);
+$serviceManager->setShared('C', false);
+$serviceManager->setShared('D', false);
+$serviceManager->setShared('E', false);
+$serviceManager->setShared('F', false);
+$serviceManager->setShared('G', false);
+$serviceManager->setShared('H', false);
+$serviceManager->setShared('I', false);
+$serviceManager->setShared('J', false);
for ($i = 0; $i < $argv[1]; $i++) {
$j = $serviceManager->get('J');
diff --git a/zend-servicemanager/test6a.php b/zend-servicemanager/test6a.php
new file mode 100644
index 0000000..96f2e4c
--- /dev/null
+++ b/zend-servicemanager/test6a.php
@@ -0,0 +1,40 @@
+ [
+ 'A' => ReflectionBasedAbstractFactory::class,
+ 'B' => ReflectionBasedAbstractFactory::class,
+ 'C' => ReflectionBasedAbstractFactory::class,
+ 'D' => ReflectionBasedAbstractFactory::class,
+ 'E' => ReflectionBasedAbstractFactory::class,
+ 'F' => ReflectionBasedAbstractFactory::class,
+ 'G' => ReflectionBasedAbstractFactory::class,
+ 'H' => ReflectionBasedAbstractFactory::class,
+ 'I' => ReflectionBasedAbstractFactory::class,
+ 'J' => ReflectionBasedAbstractFactory::class,
+ ],
+]);
+$serviceManager->setShared('A', false);
+$serviceManager->setShared('B', false);
+$serviceManager->setShared('C', false);
+$serviceManager->setShared('D', false);
+$serviceManager->setShared('E', false);
+$serviceManager->setShared('F', false);
+$serviceManager->setShared('G', false);
+$serviceManager->setShared('H', false);
+$serviceManager->setShared('I', false);
+$serviceManager->setShared('J', false);
+
+for ($i = 0; $i < $argv[1]; $i++) {
+ $j = $serviceManager->get('J');
+}
+
+
+$results = [
+ 'time' => 0,
+ 'files' => count(get_included_files()),
+ 'memory' => memory_get_peak_usage()/1024/1024
+];
+
+echo json_encode($results);
\ No newline at end of file