3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo = ["a" => 1, "b" => 2, "c" => 3, "d" => 4]; } $i = 0; $mem = memory_get_usage(); for ($i = 19999; --$i;) { $s[] = new Foo; } $mem = memory_get_usage() - $mem; echo "Memory used with static init: ", $mem, PHP_EOL; class Bar { private $bar; function __construct() { $this->bar = ["a" => 1, "b" => 2, "c" => 3, "d" => 4]; } } $mem = memory_get_usage(); for ($i = 19999; --$i;) { $f[] = new Bar; } $mem = memory_get_usage() - $mem; echo "Memory used with dynamic init: ", $mem, PHP_EOL;
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 = 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 24
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 24
Branch analysis from position: 30
Branch analysis from position: 24
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
Branch analysis from position: 6
filename:       /in/llpgA
function name:  (null)
number of ops:  38
compiled vars:  !0 = $i, !1 = $mem, !2 = $s, !3 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 0
    5     1        INIT_FCALL                                               'memory_get_usage'
          2        DO_ICALL                                         $5      
          3        ASSIGN                                                   !1, $5
    6     4        ASSIGN                                                   !0, 19999
          5      > JMP                                                      ->10
    7     6    >   NEW                                              $9      'Foo'
          7        DO_FCALL                                      0          
          8        ASSIGN_DIM                                               !2
          9        OP_DATA                                                  $9
    6    10    >   PRE_DEC                                          ~11     !0
         11      > JMPNZ                                                    ~11, ->6
    9    12    >   INIT_FCALL                                               'memory_get_usage'
         13        DO_ICALL                                         $12     
         14        SUB                                              ~13     $12, !1
         15        ASSIGN                                                   !1, ~13
   10    16        ECHO                                                     'Memory+used+with+static+init%3A+'
         17        ECHO                                                     !1
         18        ECHO                                                     '%0A'
   13    19        INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $15     
         21        ASSIGN                                                   !1, $15
   14    22        ASSIGN                                                   !0, 19999
         23      > JMP                                                      ->28
   15    24    >   NEW                                              $19     'Bar'
         25        DO_FCALL                                      0          
         26        ASSIGN_DIM                                               !3
         27        OP_DATA                                                  $19
   14    28    >   PRE_DEC                                          ~21     !0
         29      > JMPNZ                                                    ~21, ->24
   17    30    >   INIT_FCALL                                               'memory_get_usage'
         31        DO_ICALL                                         $22     
         32        SUB                                              ~23     $22, !1
         33        ASSIGN                                                   !1, ~23
   18    34        ECHO                                                     'Memory+used+with+dynamic+init%3A+'
         35        ECHO                                                     !1
         36        ECHO                                                     '%0A'
         37      > RETURN                                                   1

Class Foo: [no user functions]
Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/llpgA
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN_OBJ                                               'bar'
          1        OP_DATA                                                  <array>
          2      > RETURN                                                   null

End of function __construct

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.1 ms | 1400 KiB | 15 Q