3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Service { public $class; public function __construct($class) { $this->class = $class; } } class Container { public $services = array(); } $start = memory_get_usage(); $container = new Container(); for ($i = 0; $i < 1000; $i++) { $container->services[] = new Service('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service objects: '.$delta, PHP_EOL; $start = memory_get_usage(); $container1 = new Container(); for ($i = 0; $i < 1000; $i++) { $container1->services[] = array('Foo'.$i); } $delta = memory_get_usage() - $start; echo 'Memory usage of 1000 service arrays: '.$delta;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 8
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 33
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 33
Branch analysis from position: 41
Branch analysis from position: 33
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 8
Branch analysis from position: 18
Branch analysis from position: 8
filename:       /in/ttnZt
function name:  (null)
number of ops:  48
compiled vars:  !0 = $start, !1 = $container, !2 = $i, !3 = $delta, !4 = $container1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        DO_ICALL                                         $5      
          2        ASSIGN                                                   !0, $5
   20     3        NEW                                              $7      'Container'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
   22     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->16
   23     8    >   NEW                                              $13     'Service'
          9        CONCAT                                           ~14     'Foo', !2
         10        SEND_VAL_EX                                              ~14
         11        DO_FCALL                                      0          
         12        FETCH_OBJ_W                                      $11     !1, 'services'
         13        ASSIGN_DIM                                               $11
         14        OP_DATA                                                  $13
   22    15        PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, 1000
         17      > JMPNZ                                                    ~17, ->8
   26    18    >   INIT_FCALL                                               'memory_get_usage'
         19        DO_ICALL                                         $18     
         20        SUB                                              ~19     $18, !0
         21        ASSIGN                                                   !3, ~19
   28    22        CONCAT                                           ~21     'Memory+usage+of+1000+service+objects%3A+', !3
         23        ECHO                                                     ~21
         24        ECHO                                                     '%0A'
   30    25        INIT_FCALL                                               'memory_get_usage'
         26        DO_ICALL                                         $22     
         27        ASSIGN                                                   !0, $22
   32    28        NEW                                              $24     'Container'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !4, $24
   34    31        ASSIGN                                                   !2, 0
         32      > JMP                                                      ->39
   35    33    >   CONCAT                                           ~30     'Foo', !2
         34        INIT_ARRAY                                       ~31     ~30
         35        FETCH_OBJ_W                                      $28     !4, 'services'
         36        ASSIGN_DIM                                               $28
         37        OP_DATA                                                  ~31
   34    38        PRE_INC                                                  !2
         39    >   IS_SMALLER                                               !2, 1000
         40      > JMPNZ                                                    ~33, ->33
   38    41    >   INIT_FCALL                                               'memory_get_usage'
         42        DO_ICALL                                         $34     
         43        SUB                                              ~35     $34, !0
         44        ASSIGN                                                   !3, ~35
   40    45        CONCAT                                           ~37     'Memory+usage+of+1000+service+arrays%3A+', !3
         46        ECHO                                                     ~37
         47      > RETURN                                                   1

Class Service:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ttnZt
function name:  __construct
number of ops:  4
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'class'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

End of class Service.

Class Container: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.81 ms | 1400 KiB | 15 Q