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