3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array_fill(0, 100, uniqid('', false)); $array2 = $array; $timer = microtime(true); $k = $j = 0; for ($i = 0; $i < 10; $i++) { while (list($key, $value) = each($array)) { $j++; } } printf("While list each %.3f sec\n", microtime(true) - $timer); echo $j . ' iterations' . PHP_EOL;; $timer = microtime(true); for ($i = 0; $i < 10; $i++) { foreach ($array2 as $key => &$value) { $k++; } } printf("Foreach %.3f sec\n", microtime(true) - $timer); echo $k . ' iterations' . PHP_EOL;;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 49
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
2 jumps found. (Code = 125) Position 1 = 50, Position 2 = 54
Branch analysis from position: 50
2 jumps found. (Code = 126) Position 1 = 51, Position 2 = 54
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 49
Branch analysis from position: 58
Branch analysis from position: 49
Branch analysis from position: 54
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 20
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
Branch analysis from position: 19
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 20
Branch analysis from position: 29
Branch analysis from position: 20
filename:       /in/KIpKU
function name:  (null)
number of ops:  70
compiled vars:  !0 = $array, !1 = $array2, !2 = $timer, !3 = $k, !4 = $j, !5 = $i, !6 = $key, !7 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 100
          3        INIT_FCALL                                               'uniqid'
          4        SEND_VAL                                                 ''
          5        SEND_VAL                                                 <false>
          6        DO_ICALL                                         $8      
          7        SEND_VAR                                                 $8
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !0, $9
    4    10        ASSIGN                                                   !1, !0
    5    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !2, $12
    6    15        ASSIGN                                           ~14     !4, 0
         16        ASSIGN                                                   !3, ~14
    7    17        ASSIGN                                                   !5, 0
         18      > JMP                                                      ->30
    8    19    > > JMP                                                      ->21
    9    20    >   PRE_INC                                                  !4
    8    21    >   INIT_FCALL_BY_NAME                                       'each'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0  $18     
         24        FETCH_LIST_R                                     $19     $18, 0
         25        ASSIGN                                                   !6, $19
         26        FETCH_LIST_R                                     $21     $18, 1
         27        ASSIGN                                                   !7, $21
         28      > JMPNZ                                                    $18, ->20
    7    29    >   PRE_INC                                                  !5
         30    >   IS_SMALLER                                               !5, 10
         31      > JMPNZ                                                    ~24, ->19
   12    32    >   INIT_FCALL                                               'printf'
         33        SEND_VAL                                                 'While+list+each+%25.3f+sec%0A'
         34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $25     
         37        SUB                                              ~26     $25, !2
         38        SEND_VAL                                                 ~26
         39        DO_ICALL                                                 
   13    40        CONCAT                                           ~28     !4, '+iterations'
         41        CONCAT                                           ~29     ~28, '%0A'
         42        ECHO                                                     ~29
   14    43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $30     
         46        ASSIGN                                                   !2, $30
   15    47        ASSIGN                                                   !5, 0
         48      > JMP                                                      ->56
   16    49    > > FE_RESET_RW                                      $33     !1, ->54
         50    > > FE_FETCH_RW                                      ~34     $33, !7, ->54
         51    >   ASSIGN                                                   !6, ~34
   17    52        PRE_INC                                                  !3
   16    53      > JMP                                                      ->50
         54    >   FE_FREE                                                  $33
   15    55        PRE_INC                                                  !5
         56    >   IS_SMALLER                                               !5, 10
         57      > JMPNZ                                                    ~38, ->49
   20    58    >   INIT_FCALL                                               'printf'
         59        SEND_VAL                                                 'Foreach+%25.3f+sec%0A'
         60        INIT_FCALL                                               'microtime'
         61        SEND_VAL                                                 <true>
         62        DO_ICALL                                         $39     
         63        SUB                                              ~40     $39, !2
         64        SEND_VAL                                                 ~40
         65        DO_ICALL                                                 
   21    66        CONCAT                                           ~42     !3, '+iterations'
         67        CONCAT                                           ~43     ~42, '%0A'
         68        ECHO                                                     ~43
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.93 ms | 1008 KiB | 17 Q