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); delta(); //to set initial value 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
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/Tl2go
function name:  (null)
number of ops:  35
compiled vars:  !0 = $a, !1 = $x, !2 = $v, !3 = $k
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
   12     5        INIT_FCALL                                               'delta'
          6        DO_FCALL                                      0          
   13     7        ASSIGN                                                   !1, 0
          8      > JMP                                                      ->12
   14     9    >   FETCH_DIM_RW                                     $8      !0, !1
         10        PRE_INC                                                  $8
   13    11        PRE_INC                                                  !1
         12    >   COUNT                                            ~11     !0
         13        IS_SMALLER                                               !1, ~11
         14      > JMPNZ                                                    ~12, ->9
   17    15    >   INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'delta'
         17        DO_FCALL                                      0  $13     
         18        CONCAT                                           ~14     'for+loop+and+increment+delta%3A', $13
         19        SEND_VAL                                                 ~14
         20        DO_ICALL                                                 
   19    21      > FE_RESET_R                                       $16     !0, ->27
         22    > > FE_FETCH_R                                       ~17     $16, !2, ->27
         23    >   ASSIGN                                                   !3, ~17
   20    24        FETCH_DIM_RW                                     $19     !0, !3
         25        PRE_INC                                                  $19
   19    26      > JMP                                                      ->22
         27    >   FE_FREE                                                  $16
   23    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'delta'
         30        DO_FCALL                                      0  $21     
         31        CONCAT                                           ~22     'foreach+loop+and+increment+delta%3A+', $21
         32        SEND_VAL                                                 ~22
         33        DO_ICALL                                                 
         34      > 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/Tl2go
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:
143.23 ms | 1403 KiB | 22 Q