3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __construct() { for ($i = 0; $i < 1000; ++$i) { $this->result[] = rand(1, 1000); } } function object() { is_object($this); } } function checkMemory($memoryAtStart) { for ($i = 0; $i < 1; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); $memoryAtStart = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); $memoryAtStart = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); is_object($object); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); } $memoryAtStart = null; for ($x=0; $x<100; $x++) { if ($memoryAtStart === null) { $memoryAtStart = memory_get_usage(); } checkMemory($memoryAtStart); gc_collect_cycles(); }
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 = 3
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 3
Branch analysis from position: 16
Branch analysis from position: 3
Branch analysis from position: 8
filename:       /in/dPZ2R
function name:  (null)
number of ops:  17
compiled vars:  !0 = $memoryAtStart, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   ASSIGN                                                   !0, null
   48     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->14
   50     3    >   TYPE_CHECK                                    2          !0
          4      > JMPZ                                                     ~4, ->8
   51     5    >   INIT_FCALL                                               'memory_get_usage'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   54     8    >   INIT_FCALL                                               'checkmemory'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0          
   55    11        INIT_FCALL                                               'gc_collect_cycles'
         12        DO_ICALL                                                 
   48    13        PRE_INC                                                  !1
         14    >   IS_SMALLER                                               !1, 100
         15      > JMPNZ                                                    ~10, ->3
   56    16    > > RETURN                                                   1

Function checkmemory:
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 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 23
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 43
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 43
Branch analysis from position: 52
Branch analysis from position: 43
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 23
Branch analysis from position: 32
Branch analysis from position: 23
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/dPZ2R
function name:  checkMemory
number of ops:  59
compiled vars:  !0 = $memoryAtStart, !1 = $i, !2 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   21     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->10
   22     3    >   NEW                                              $4      'Test'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $4
   23     6        INIT_METHOD_CALL                                         !2, 'object'
          7        DO_FCALL                                      0          
   24     8        UNSET_CV                                                 !2
   21     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 1
         11      > JMPNZ                                                    ~9, ->3
   26    12    >   INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'memory_get_usage'
         14        DO_ICALL                                         $10     
         15        SUB                                              ~11     $10, !0
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                                 
   28    18        INIT_FCALL                                               'memory_get_usage'
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !0, $13
   29    21        ASSIGN                                                   !1, 0
         22      > JMP                                                      ->30
   30    23    >   NEW                                              $16     'Test'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !2, $16
   31    26        INIT_METHOD_CALL                                         !2, 'object'
         27        DO_FCALL                                      0          
   32    28        UNSET_CV                                                 !2
   29    29        PRE_INC                                                  !1
         30    >   IS_SMALLER                                               !1, 100
         31      > JMPNZ                                                    ~21, ->23
   34    32    >   INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'memory_get_usage'
         34        DO_ICALL                                         $22     
         35        SUB                                              ~23     $22, !0
         36        SEND_VAL                                                 ~23
         37        DO_ICALL                                                 
   36    38        INIT_FCALL                                               'memory_get_usage'
         39        DO_ICALL                                         $25     
         40        ASSIGN                                                   !0, $25
   37    41        ASSIGN                                                   !1, 0
         42      > JMP                                                      ->50
   38    43    >   NEW                                              $28     'Test'
         44        DO_FCALL                                      0          
         45        ASSIGN                                                   !2, $28
   39    46        TYPE_CHECK                                  256  ~31     !2
         47        FREE                                                     ~31
   40    48        UNSET_CV                                                 !2
   37    49        PRE_INC                                                  !1
         50    >   IS_SMALLER                                               !1, 100
         51      > JMPNZ                                                    ~33, ->43
   42    52    >   INIT_FCALL                                               'var_dump'
         53        INIT_FCALL                                               'memory_get_usage'
         54        DO_ICALL                                         $34     
         55        SUB                                              ~35     $34, !0
         56        SEND_VAL                                                 ~35
         57        DO_ICALL                                                 
   44    58      > RETURN                                                   null

End of function checkmemory

Class Test:
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 = 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 2
Branch analysis from position: 12
Branch analysis from position: 2
filename:       /in/dPZ2R
function name:  __construct
number of ops:  13
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->10
    7     2    >   INIT_FCALL                                               'rand'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 1000
          5        DO_ICALL                                         $4      
          6        FETCH_OBJ_W                                      $2      'result'
          7        ASSIGN_DIM                                               $2
          8        OP_DATA                                                  $4
    6     9        PRE_INC                                                  !0
         10    >   IS_SMALLER                                               !0, 1000
         11      > JMPNZ                                                    ~6, ->2
    9    12    > > RETURN                                                   null

End of function __construct

Function object:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dPZ2R
function name:  object
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_THIS                                       ~0      
          1        TYPE_CHECK                                  256  ~1      ~0
          2        FREE                                                     ~1
   12     3      > RETURN                                                   null

End of function object

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.94 ms | 1411 KiB | 22 Q