3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.67 ms | 1400 KiB | 23 Q