3v4l.org

run code in 300+ PHP versions simultaneously
<?php function delta() { static $lastmem=0; return memory_get_peak_usage() - $lastmem; } $a=range(1, 500); foreach($a as $k=>$v) { } var_dump(memory_get_peak_usage()); foreach($a as $k=>$v) { echo $v; } echo "\n"; var_dump('foreach loop and echo delta: '.delta()); for($x=0;$x<sizeof($a);$x++) { $a[$x]++; } var_dump('for loop and increment delta:'.delta()); foreach($a as $k=>$v) { $a[$k]++; } var_dump('foreach loop and increment delta: '.delta());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 30
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 30
Branch analysis from position: 36
Branch analysis from position: 30
Branch analysis from position: 20
Branch analysis from position: 9
filename:       /in/kuuSt
function name:  (null)
number of ops:  56
compiled vars:  !0 = $a, !1 = $v, !2 = $k, !3 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 500
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !0, $4
    9     5      > FE_RESET_R                                       $6      !0, ->9
          6    > > FE_FETCH_R                                       ~7      $6, !1, ->9
          7    >   ASSIGN                                                   !2, ~7
          8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $6
   13    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'memory_get_peak_usage'
         12        DO_ICALL                                         $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   15    15      > FE_RESET_R                                       $11     !0, ->20
         16    > > FE_FETCH_R                                       ~12     $11, !1, ->20
         17    >   ASSIGN                                                   !2, ~12
   16    18        ECHO                                                     !1
   15    19      > JMP                                                      ->16
         20    >   FE_FREE                                                  $11
   19    21        ECHO                                                     '%0A'
   21    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'delta'
         24        DO_FCALL                                      0  $14     
         25        CONCAT                                           ~15     'foreach+loop+and+echo+delta%3A+', $14
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                                 
   23    28        ASSIGN                                                   !3, 0
         29      > JMP                                                      ->33
   24    30    >   FETCH_DIM_RW                                     $18     !0, !3
         31        PRE_INC                                                  $18
   23    32        PRE_INC                                                  !3
         33    >   COUNT                                            ~21     !0
         34        IS_SMALLER                                               !3, ~21
         35      > JMPNZ                                                    ~22, ->30
   27    36    >   INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'delta'
         38        DO_FCALL                                      0  $23     
         39        CONCAT                                           ~24     'for+loop+and+increment+delta%3A', $23
         40        SEND_VAL                                                 ~24
         41        DO_ICALL                                                 
   29    42      > FE_RESET_R                                       $26     !0, ->48
         43    > > FE_FETCH_R                                       ~27     $26, !1, ->48
         44    >   ASSIGN                                                   !2, ~27
   30    45        FETCH_DIM_RW                                     $29     !0, !2
         46        PRE_INC                                                  $29
   29    47      > JMP                                                      ->43
         48    >   FE_FREE                                                  $26
   33    49        INIT_FCALL                                               'var_dump'
         50        INIT_FCALL                                               'delta'
         51        DO_FCALL                                      0  $31     
         52        CONCAT                                           ~32     'foreach+loop+and+increment+delta%3A+', $31
         53        SEND_VAL                                                 ~32
         54        DO_ICALL                                                 
         55      > RETURN                                                   1

Function delta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kuuSt
function name:  delta
number of ops:  6
compiled vars:  !0 = $lastmem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   BIND_STATIC                                              !0
    5     1        INIT_FCALL                                               'memory_get_peak_usage'
          2        DO_ICALL                                         $1      
          3        SUB                                              ~2      $1, !0
          4      > RETURN                                                   ~2
    6     5*     > RETURN                                                   null

End of function delta

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.02 ms | 1402 KiB | 22 Q