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