3v4l.org

run code in 300+ PHP versions simultaneously
<?php function it_fe($array) { foreach ($array as $v) { } } function it_for($array) { for ($j = 0, $c = count($array); $j < $c; $j++) { $v = $array[$j]; } } $array = range(0, 50000); $n = 100; $t = microtime(true); for ($i = 0; $i < $n; $i++) { it_fe($array); } var_dump(microtime(true) - $t); $t = microtime(true); for ($i = 0; $i < $n; $i++) { it_for($array); } var_dump(microtime(true) - $t);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
Branch analysis from position: 31
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
Branch analysis from position: 12
filename:       /in/UAn6M
function name:  (null)
number of ops:  45
compiled vars:  !0 = $array, !1 = $n, !2 = $t, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 50000
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !0, $4
   14     5        ASSIGN                                                   !1, 100
   16     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
   17    10        ASSIGN                                                   !3, 0
         11      > JMP                                                      ->16
   18    12    >   INIT_FCALL                                               'it_fe'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0          
   17    15        PRE_INC                                                  !3
         16    >   IS_SMALLER                                               !3, !1
         17      > JMPNZ                                                    ~12, ->12
   20    18    >   INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $13     
         22        SUB                                              ~14     $13, !2
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                                 
   22    25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $16     
         28        ASSIGN                                                   !2, $16
   23    29        ASSIGN                                                   !3, 0
         30      > JMP                                                      ->35
   24    31    >   INIT_FCALL                                               'it_for'
         32        SEND_VAR                                                 !0
         33        DO_FCALL                                      0          
   23    34        PRE_INC                                                  !3
         35    >   IS_SMALLER                                               !3, !1
         36      > JMPNZ                                                    ~21, ->31
   26    37    >   INIT_FCALL                                               'var_dump'
         38        INIT_FCALL                                               'microtime'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $22     
         41        SUB                                              ~23     $22, !2
         42        SEND_VAL                                                 ~23
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Function it_fe:
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/UAn6M
function name:  it_fe
number of ops:  6
compiled vars:  !0 = $array, !1 = $v
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
    5     5      > RETURN                                                   null

End of function it_fe

Function it_for:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
Branch analysis from position: 5
filename:       /in/UAn6M
function name:  it_for
number of ops:  11
compiled vars:  !0 = $array, !1 = $j, !2 = $c, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, 0
          2        COUNT                                            ~5      !0
          3        ASSIGN                                                   !2, ~5
          4      > JMP                                                      ->8
    8     5    >   FETCH_DIM_R                                      ~7      !0, !1
          6        ASSIGN                                                   !3, ~7
    7     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, !2
          9      > JMPNZ                                                    ~10, ->5
   10    10    > > RETURN                                                   null

End of function it_for

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.32 ms | 1407 KiB | 21 Q