Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/vendor/autoload.php';
- use Kanian\ContainerX\ContainerX;
- class A
- {
- public function __construct()
- {
- }
- }
- class B extends A
- {
- public function __construct(A $a)
- {
- }
- }
- class C extends B
- {
- public function __construct(B $b)
- {
- }
- }
- class D extends C
- {
- public function __construct(C $c)
- {
- }
- }
- class E extends D
- {
- public function __construct(D $d)
- {
- }
- }
- class F extends E
- {
- public function __construct(E $e)
- {
- }
- }
- class G extends F
- {
- public function __construct(F $f)
- {
- }
- }
- class H extends G
- {
- public function __construct(G $g)
- {
- }
- }
- class I extends H
- {
- public function __construct(H $h)
- {
- }
- }
- class J extends I
- {
- public function __construct(I $i)
- {
- }
- }
- $c = new ContainerX();
- $c['A'] = function ($c = null) {
- return new A;
- };
- $c['B'] = function ($c = null) {
- return new B($c['A']);
- };
- $c['C'] = function ($c = null) {
- return new C($c['B']);
- };
- $c['D'] = function ($c = null) {
- return new D($c['C']);
- };
- $c['E'] = function ($c = null) {
- return new E($c['D']);
- };
- $c['F'] = function ($c = null) {
- return new F($c['E']);
- };
- $c['G'] = function ($c = null) {
- return new G($c['F']);
- };
- $c['H'] = function ($c = null) {
- return new H($c['G']);
- };
- $c['I'] = function ($c = null) {
- return new I($c['H']);
- };
- $c['J'] = function ($c = null) {
- return new J($c['I']);
- };
- // Let loading happen to ensure that any required classes were autoloaded before measuring the time.
- $u = $c['J'];
- unset($u);
- $t1 = microtime(true);
- for ($i = 0; $i < 10000; $i++) {
- $u = $c['J'];
- }
- $t2 = microtime(true);
- $results = [
- 'time' => $t2 - $t1,
- 'files' => count(get_included_files()),
- 'memory' => memory_get_peak_usage() / 1024 / 1024,
- ];
- echo json_encode($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement