3v4l.org

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

Function delta:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/i3C1l
function name:  delta
number of ops:  13
compiled vars:  !0 = $lastmem, !1 = $delta
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                                         $2      
          3        SUB                                              ~3      $2, !0
          4        ASSIGN                                                   !1, ~3
    6     5        IS_EQUAL                                                 !0, 0
          6      > JMPZ                                                     ~5, ->8
          7    >   ASSIGN                                                   !1, 0
    7     8    >   INIT_FCALL                                               'memory_get_peak_usage'
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !0, $7
    8    11      > RETURN                                                   !1
    9    12*     > RETURN                                                   null

End of function delta

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.13 ms | 1403 KiB | 22 Q