3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 'On'); // Variant A: servicecontainer met services in een array class ServiceContainer { private $Services; public function __construct() { $this->Services = array(); for ($i = 1; $i <= 100; $i++) { $this->Services[mt_rand()] = array( 'class' => 'FileCacher', 'path' => 'some/path', ); } } } // Variant B: services met één object per service class Service { public function __construct() { $this->Class = 'class'; $this->Path = 'some/path'; } } class Services { private $Services; public function __construct() { $this->Services = array(); for ($i = 1; $i <= 100; $i++) { $this->Services[mt_rand()] = new Service(); } } } $nulmeting = memory_get_usage(); $a = new ServiceContainer(); echo '<p>Versie A verstookt ', memory_get_usage() - $nulmeting, ' bytes.</p>'; $nulmeting = memory_get_usage(); $b = new Services(); echo '<p>Versie B verstookt ', memory_get_usage() - $nulmeting, ' bytes.</p>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F29S9
function name:  (null)
number of ops:  32
compiled vars:  !0 = $nulmeting, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    3     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 'On'
          6        DO_ICALL                                                 
   45     7        INIT_FCALL                                               'memory_get_usage'
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !0, $5
   46    10        NEW                                              $7      'ServiceContainer'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $7
   47    13        ECHO                                                     '%3Cp%3EVersie+A+verstookt+'
         14        INIT_FCALL                                               'memory_get_usage'
         15        DO_ICALL                                         $10     
         16        SUB                                              ~11     $10, !0
         17        ECHO                                                     ~11
         18        ECHO                                                     '+bytes.%3C%2Fp%3E'
   49    19        INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !0, $12
   50    22        NEW                                              $14     'Services'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !2, $14
   51    25        ECHO                                                     '%3Cp%3EVersie+B+verstookt+'
         26        INIT_FCALL                                               'memory_get_usage'
         27        DO_ICALL                                         $17     
         28        SUB                                              ~18     $17, !0
         29        ECHO                                                     ~18
         30        ECHO                                                     '+bytes.%3C%2Fp%3E'
         31      > RETURN                                                   1

Class ServiceContainer:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
Branch analysis from position: 4
filename:       /in/F29S9
function name:  __construct
number of ops:  13
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN_OBJ                                               'Services'
          1        OP_DATA                                                  <array>
   13     2        ASSIGN                                                   !0, 1
          3      > JMP                                                      ->10
   14     4    >   INIT_FCALL                                               'mt_rand'
          5        DO_ICALL                                         $4      
          6        FETCH_OBJ_W                                      $3      'Services'
          7        ASSIGN_DIM                                               $3, $4
   15     8        OP_DATA                                                  <array>
   13     9        PRE_INC                                                  !0
         10    >   IS_SMALLER_OR_EQUAL                                      !0, 100
         11      > JMPNZ                                                    ~7, ->4
   19    12    > > RETURN                                                   null

End of function __construct

End of class ServiceContainer.

Class Service:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F29S9
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN_OBJ                                               'Class'
          1        OP_DATA                                                  'class'
   28     2        ASSIGN_OBJ                                               'Path'
          3        OP_DATA                                                  'some%2Fpath'
   29     4      > RETURN                                                   null

End of function __construct

End of class Service.

Class Services:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
Branch analysis from position: 4
filename:       /in/F29S9
function name:  __construct
number of ops:  15
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN_OBJ                                               'Services'
          1        OP_DATA                                                  <array>
   39     2        ASSIGN                                                   !0, 1
          3      > JMP                                                      ->12
   40     4    >   INIT_FCALL                                               'mt_rand'
          5        DO_ICALL                                         $4      
          6        NEW                                              $6      'Service'
          7        DO_FCALL                                      0          
          8        FETCH_OBJ_W                                      $3      'Services'
          9        ASSIGN_DIM                                               $3, $4
         10        OP_DATA                                                  $6
   39    11        PRE_INC                                                  !0
         12    >   IS_SMALLER_OR_EQUAL                                      !0, 100
         13      > JMPNZ                                                    ~9, ->4
   42    14    > > RETURN                                                   null

End of function __construct

End of class Services.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.7 ms | 1400 KiB | 21 Q