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; $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, PHP_EOL;
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 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 30
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 30
Branch analysis from position: 40
Branch analysis from position: 30
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/Cc9VI
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
   30    22        NEW                                              $20     'Container'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !0, $20
   32    25        INIT_FCALL                                               'memory_get_usage'
         26        DO_ICALL                                         $23     
         27        ASSIGN                                                   !1, $23
   34    28        ASSIGN                                                   !2, 0
         29      > JMP                                                      ->38
   35    30    >   NEW                                              $28     'Service'
         31        CONCAT                                           ~29     'Foo', !2
         32        SEND_VAL_EX                                              ~29
         33        DO_FCALL                                      0          
         34        FETCH_OBJ_W                                      $26     !0, 'services'
         35        ASSIGN_DIM                                               $26
         36        OP_DATA                                                  $28
   34    37        PRE_INC                                                  !2
         38    >   IS_SMALLER                                               !2, 1000
         39      > JMPNZ                                                    ~32, ->30
   38    40    >   INIT_FCALL                                               'memory_get_usage'
         41        DO_ICALL                                         $33     
         42        SUB                                              ~34     $33, !1
         43        ASSIGN                                                   !3, ~34
   40    44        CONCAT                                           ~36     'Memory+usage+of+1000+service+objects%3A+', !3
         45        ECHO                                                     ~36
         46        ECHO                                                     '%0A'
         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/Cc9VI
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:
154.62 ms | 1400 KiB | 15 Q