3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* How many times the code under test should run in each function */ define('LOOP',10000); function f1() { for($i=0; $i<LOOP; ++$i) { foreach (range(0, 100) as $i) { echo $i . PHP_EOL; } } } function f2() { for($i=0; $i<LOOP; ++$i) { for ($i = 0; $i <= 100; $i++) { echo $i . PHP_EOL; } } } $start = microtime(true); f1(); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2(); $stop = microtime(true); $time2 = $stop - $start; echo $time1 . "\t"; echo $time2 . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mSCI9
function name:  (null)
number of ops:  33
compiled vars:  !0 = $start, !1 = $stop, !2 = $time1, !3 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'LOOP'
          2        SEND_VAL                                                 10000
          3        DO_ICALL                                                 
   19     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   20     8        INIT_FCALL                                               'f1'
          9        DO_FCALL                                      0          
   21    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !1, $8
   22    14        SUB                                              ~10     !1, !0
         15        ASSIGN                                                   !2, ~10
   24    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !0, $12
   25    20        INIT_FCALL                                               'f2'
         21        DO_FCALL                                      0          
   26    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !1, $15
   27    26        SUB                                              ~17     !1, !0
         27        ASSIGN                                                   !3, ~17
   29    28        CONCAT                                           ~19     !2, '%09'
         29        ECHO                                                     ~19
   30    30        CONCAT                                           ~20     !3, '%0A'
         31        ECHO                                                     ~20
         32      > RETURN                                                   1

Function f1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 2
Branch analysis from position: 16
Branch analysis from position: 2
Branch analysis from position: 11
filename:       /in/mSCI9
function name:  f1
number of ops:  17
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->13
    7     2    >   INIT_FCALL                                               'range'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 100
          5        DO_ICALL                                         $2      
          6      > FE_RESET_R                                       $3      $2, ->11
          7    > > FE_FETCH_R                                               $3, !0, ->11
    8     8    >   CONCAT                                           ~4      !0, '%0A'
          9        ECHO                                                     ~4
    7    10      > JMP                                                      ->7
         11    >   FE_FREE                                                  $3
    6    12        PRE_INC                                                  !0
         13    >   FETCH_CONSTANT                                   ~6      'LOOP'
         14        IS_SMALLER                                               !0, ~6
         15      > JMPNZ                                                    ~7, ->2
   11    16    > > RETURN                                                   null

End of function f1

Function f2:
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 = 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
Branch analysis from position: 2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
Branch analysis from position: 4
filename:       /in/mSCI9
function name:  f2
number of ops:  14
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->10
   14     2    >   ASSIGN                                                   !0, 0
          3      > JMP                                                      ->7
   15     4    >   CONCAT                                           ~3      !0, '%0A'
          5        ECHO                                                     ~3
   14     6        PRE_INC                                                  !0
          7    >   IS_SMALLER_OR_EQUAL                                      !0, 100
          8      > JMPNZ                                                    ~5, ->4
   13     9    >   PRE_INC                                                  !0
         10    >   FETCH_CONSTANT                                   ~7      'LOOP'
         11        IS_SMALLER                                               !0, ~7
         12      > JMPNZ                                                    ~8, ->2
   18    13    > > RETURN                                                   null

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.67 ms | 1407 KiB | 21 Q