Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3. use Kanian\ContainerX\ContainerX;
  4.  
  5.  
  6. class A
  7. {
  8. public function __construct()
  9. {
  10.  
  11. }
  12. }
  13. class B extends A
  14. {
  15. public function __construct(A $a)
  16. {
  17. }
  18. }
  19. class C extends B
  20. {
  21. public function __construct(B $b)
  22. {
  23. }
  24. }
  25. class D extends C
  26. {
  27. public function __construct(C $c)
  28. {
  29. }
  30. }
  31. class E extends D
  32. {
  33. public function __construct(D $d)
  34. {
  35. }
  36. }
  37. class F extends E
  38. {
  39. public function __construct(E $e)
  40. {
  41. }
  42. }
  43. class G extends F
  44. {
  45. public function __construct(F $f)
  46. {
  47. }
  48. }
  49. class H extends G
  50. {
  51. public function __construct(G $g)
  52. {
  53. }
  54. }
  55. class I extends H
  56. {
  57. public function __construct(H $h)
  58. {
  59. }
  60. }
  61. class J extends I
  62. {
  63. public function __construct(I $i)
  64. {
  65. }
  66. }
  67. $c = new ContainerX();
  68. $c['A'] = function ($c = null) {
  69. return new A;
  70. };
  71. $c['B'] = function ($c = null) {
  72. return new B($c['A']);
  73. };
  74. $c['C'] = function ($c = null) {
  75. return new C($c['B']);
  76. };
  77. $c['D'] = function ($c = null) {
  78. return new D($c['C']);
  79. };
  80. $c['E'] = function ($c = null) {
  81. return new E($c['D']);
  82. };
  83. $c['F'] = function ($c = null) {
  84. return new F($c['E']);
  85. };
  86. $c['G'] = function ($c = null) {
  87. return new G($c['F']);
  88. };
  89. $c['H'] = function ($c = null) {
  90. return new H($c['G']);
  91. };
  92. $c['I'] = function ($c = null) {
  93. return new I($c['H']);
  94. };
  95. $c['J'] = function ($c = null) {
  96. return new J($c['I']);
  97. };
  98. // Let loading happen to ensure that any required classes were autoloaded before measuring the time.
  99. $u = $c['J'];
  100. unset($u);
  101.  
  102. $t1 = microtime(true);
  103. for ($i = 0; $i < 10000; $i++) {
  104. $u = $c['J'];
  105. }
  106. $t2 = microtime(true);
  107. $results = [
  108. 'time' => $t2 - $t1,
  109. 'files' => count(get_included_files()),
  110. 'memory' => memory_get_peak_usage() / 1024 / 1024,
  111. ];
  112. echo json_encode($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement