3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ref(&$array) { foreach ($array as $item) { $item; } } function notref($array) { foreach ($array as $item) { $item; } } $array = range(0, 1000); $start = microtime(true); ref($array); echo 'time: '.(microtime(true) - $start).' sec'; $start = microtime(true); notref($array); echo 'time: '.(microtime(true) - $start).' sec';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPDDa
function name:  (null)
number of ops:  34
compiled vars:  !0 = $array, !1 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1000
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   17     5        INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   18     9        INIT_FCALL                                               'ref'
         10        SEND_REF                                                 !0
         11        DO_FCALL                                      0          
   19    12        INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $7      
         15        SUB                                              ~8      $7, !1
         16        CONCAT                                           ~9      'time%3A+', ~8
         17        CONCAT                                           ~10     ~9, '+sec'
         18        ECHO                                                     ~10
   20    19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !1, $11
   21    23        INIT_FCALL                                               'notref'
         24        SEND_VAR                                                 !0
         25        DO_FCALL                                      0          
   22    26        INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $14     
         29        SUB                                              ~15     $14, !1
         30        CONCAT                                           ~16     'time%3A+', ~15
         31        CONCAT                                           ~17     ~16, '+sec'
         32        ECHO                                                     ~17
         33      > RETURN                                                   1

Function ref:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/KPDDa
function name:  ref
number of ops:  6
compiled vars:  !0 = $array, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1      > FE_RESET_R                                       $2      !0, ->4
          2    > > FE_FETCH_R                                               $2, !1, ->4
          3    > > JMP                                                      ->2
          4    >   FE_FREE                                                  $2
    7     5      > RETURN                                                   null

End of function ref

Function notref:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/KPDDa
function name:  notref
number of ops:  6
compiled vars:  !0 = $array, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1      > FE_RESET_R                                       $2      !0, ->4
          2    > > FE_FETCH_R                                               $2, !1, ->4
          3    > > JMP                                                      ->2
          4    >   FE_FREE                                                  $2
   13     5      > RETURN                                                   null

End of function notref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.28 ms | 1403 KiB | 19 Q