3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); $i = 0; while ($i < $l) { $c++; $i++; } $end = microtime(true); printf('while $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); for ($i = 0; $i < $l; $i++) { $c++; } $end = microtime(true); printf('for $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); foreach ($values as $val) { $c++; } $end = microtime(true); printf('foreach %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = reset($values); while ($value) { $c++; $value = next($values); } $end = microtime(true); printf('while reset, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($val = current($values)) { $c++; next($values); } $end = microtime(true); printf('while current, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = current($values); do{ $c++; }while($value = next($values)); $end = microtime(true); printf('do while next %d iterations in %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($values) { $c++; array_shift($values); } $end = microtime(true); printf('while array_shift %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $values = array_reverse($values); while ($values) { $c++; array_pop($values); } $end = microtime(true); printf('while array_pop %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL;
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 = 14
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 43
Branch analysis from position: 47
2 jumps found. (Code = 77) Position 1 = 69, Position 2 = 72
Branch analysis from position: 69
2 jumps found. (Code = 78) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 104
Branch analysis from position: 104
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 99
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 131
Branch analysis from position: 131
2 jumps found. (Code = 44) Position 1 = 136, Position 2 = 127
Branch analysis from position: 136
2 jumps found. (Code = 44) Position 1 = 167, Position 2 = 161
Branch analysis from position: 167
1 jumps found. (Code = 42) Position 1 = 193
Branch analysis from position: 193
2 jumps found. (Code = 44) Position 1 = 194, Position 2 = 189
Branch analysis from position: 194
1 jumps found. (Code = 42) Position 1 = 224
Branch analysis from position: 224
2 jumps found. (Code = 44) Position 1 = 225, Position 2 = 220
Branch analysis from position: 225
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 220
2 jumps found. (Code = 44) Position 1 = 225, Position 2 = 220
Branch analysis from position: 225
Branch analysis from position: 220
Branch analysis from position: 189
2 jumps found. (Code = 44) Position 1 = 194, Position 2 = 189
Branch analysis from position: 194
Branch analysis from position: 189
Branch analysis from position: 161
Branch analysis from position: 127
2 jumps found. (Code = 44) Position 1 = 136, Position 2 = 127
Branch analysis from position: 136
Branch analysis from position: 127
Branch analysis from position: 99
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 99
Branch analysis from position: 105
Branch analysis from position: 99
Branch analysis from position: 72
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 43
Branch analysis from position: 47
Branch analysis from position: 43
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 14
Branch analysis from position: 18
Branch analysis from position: 14
filename:       /in/ROfld
function name:  (null)
number of ops:  237
compiled vars:  !0 = $values, !1 = $c, !2 = $start, !3 = $l, !4 = $i, !5 = $end, !6 = $val, !7 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10000
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !0, $8
    5     5        ASSIGN                                                   !1, 0
    6     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !2, $11
    7    10        COUNT                                            ~13     !0
         11        ASSIGN                                                   !3, ~13
    8    12        ASSIGN                                                   !4, 0
    9    13      > JMP                                                      ->16
   10    14    >   PRE_INC                                                  !1
   11    15        PRE_INC                                                  !4
    9    16    >   IS_SMALLER                                               !4, !3
         17      > JMPNZ                                                    ~18, ->14
   13    18    >   INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $19     
         21        ASSIGN                                                   !5, $19
   14    22        INIT_FCALL                                               'printf'
         23        SEND_VAL                                                 'while+%24i%2B%2B+%25d+iterations+in%3A+%25f+sec'
         24        SEND_VAR                                                 !1
         25        SUB                                              ~21     !5, !2
         26        SEND_VAL                                                 ~21
         27        DO_ICALL                                                 
   15    28        ECHO                                                     '%0A'
   17    29        INIT_FCALL                                               'range'
         30        SEND_VAL                                                 1
         31        SEND_VAL                                                 10000
         32        DO_ICALL                                         $23     
         33        ASSIGN                                                   !0, $23
   18    34        ASSIGN                                                   !1, 0
   19    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $26     
         38        ASSIGN                                                   !2, $26
   20    39        COUNT                                            ~28     !0
         40        ASSIGN                                                   !3, ~28
   21    41        ASSIGN                                                   !4, 0
         42      > JMP                                                      ->45
   22    43    >   PRE_INC                                                  !1
   21    44        PRE_INC                                                  !4
         45    >   IS_SMALLER                                               !4, !3
         46      > JMPNZ                                                    ~33, ->43
   24    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $34     
         50        ASSIGN                                                   !5, $34
   25    51        INIT_FCALL                                               'printf'
         52        SEND_VAL                                                 'for+%24i%2B%2B+%25d+iterations+in%3A+%25f+sec'
         53        SEND_VAR                                                 !1
         54        SUB                                              ~36     !5, !2
         55        SEND_VAL                                                 ~36
         56        DO_ICALL                                                 
   26    57        ECHO                                                     '%0A'
   28    58        INIT_FCALL                                               'range'
         59        SEND_VAL                                                 1
         60        SEND_VAL                                                 10000
         61        DO_ICALL                                         $38     
         62        ASSIGN                                                   !0, $38
   29    63        ASSIGN                                                   !1, 0
   30    64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $41     
         67        ASSIGN                                                   !2, $41
   31    68      > FE_RESET_R                                       $43     !0, ->72
         69    > > FE_FETCH_R                                               $43, !6, ->72
   32    70    >   PRE_INC                                                  !1
   31    71      > JMP                                                      ->69
         72    >   FE_FREE                                                  $43
   34    73        INIT_FCALL                                               'microtime'
         74        SEND_VAL                                                 <true>
         75        DO_ICALL                                         $45     
         76        ASSIGN                                                   !5, $45
   35    77        INIT_FCALL                                               'printf'
         78        SEND_VAL                                                 'foreach+%25d+iterations+in%3A+%25f+sec'
         79        SEND_VAR                                                 !1
         80        SUB                                              ~47     !5, !2
         81        SEND_VAL                                                 ~47
         82        DO_ICALL                                                 
   36    83        ECHO                                                     '%0A'
   39    84        INIT_FCALL                                               'range'
         85        SEND_VAL                                                 1
         86        SEND_VAL                                                 10000
         87        DO_ICALL                                         $49     
         88        ASSIGN                                                   !0, $49
   40    89        ASSIGN                                                   !1, 0
   41    90        INIT_FCALL                                               'microtime'
         91        SEND_VAL                                                 <true>
         92        DO_ICALL                                         $52     
         93        ASSIGN                                                   !2, $52
   42    94        INIT_FCALL                                               'reset'
         95        SEND_REF                                                 !0
         96        DO_ICALL                                         $54     
         97        ASSIGN                                                   !7, $54
   43    98      > JMP                                                      ->104
   44    99    >   PRE_INC                                                  !1
   45   100        INIT_FCALL                                               'next'
        101        SEND_REF                                                 !0
        102        DO_ICALL                                         $57     
        103        ASSIGN                                                   !7, $57
   43   104    > > JMPNZ                                                    !7, ->99
   47   105    >   INIT_FCALL                                               'microtime'
        106        SEND_VAL                                                 <true>
        107        DO_ICALL                                         $59     
        108        ASSIGN                                                   !5, $59
   48   109        INIT_FCALL                                               'printf'
        110        SEND_VAL                                                 'while+reset%2C+next+%25d+iterations+in%3A+%25f+sec'
        111        SEND_VAR                                                 !1
        112        SUB                                              ~61     !5, !2
        113        SEND_VAL                                                 ~61
        114        DO_ICALL                                                 
   49   115        ECHO                                                     '%0A'
   51   116        INIT_FCALL                                               'range'
        117        SEND_VAL                                                 1
        118        SEND_VAL                                                 10000
        119        DO_ICALL                                         $63     
        120        ASSIGN                                                   !0, $63
   52   121        ASSIGN                                                   !1, 0
   53   122        INIT_FCALL                                               'microtime'
        123        SEND_VAL                                                 <true>
        124        DO_ICALL                                         $66     
        125        ASSIGN                                                   !2, $66
   54   126      > JMP                                                      ->131
   55   127    >   PRE_INC                                                  !1
   56   128        INIT_FCALL                                               'next'
        129        SEND_REF                                                 !0
        130        DO_ICALL                                                 
   54   131    >   INIT_FCALL                                               'current'
        132        SEND_VAR                                                 !0
        133        DO_ICALL                                         $70     
        134        ASSIGN                                           ~71     !6, $70
        135      > JMPNZ                                                    ~71, ->127
   58   136    >   INIT_FCALL                                               'microtime'
        137        SEND_VAL                                                 <true>
        138        DO_ICALL                                         $72     
        139        ASSIGN                                                   !5, $72
   59   140        INIT_FCALL                                               'printf'
        141        SEND_VAL                                                 'while+current%2C+next+%25d+iterations+in%3A+%25f+sec'
        142        SEND_VAR                                                 !1
        143        SUB                                              ~74     !5, !2
        144        SEND_VAL                                                 ~74
        145        DO_ICALL                                                 
   60   146        ECHO                                                     '%0A'
   62   147        INIT_FCALL                                               'range'
        148        SEND_VAL                                                 1
        149        SEND_VAL                                                 10000
        150        DO_ICALL                                         $76     
        151        ASSIGN                                                   !0, $76
   63   152        ASSIGN                                                   !1, 0
   64   153        INIT_FCALL                                               'microtime'
        154        SEND_VAL                                                 <true>
        155        DO_ICALL                                         $79     
        156        ASSIGN                                                   !2, $79
   65   157        INIT_FCALL                                               'current'
        158        SEND_VAR                                                 !0
        159        DO_ICALL                                         $81     
        160        ASSIGN                                                   !7, $81
   67   161    >   PRE_INC                                                  !1
   68   162        INIT_FCALL                                               'next'
        163        SEND_REF                                                 !0
        164        DO_ICALL                                         $84     
        165        ASSIGN                                           ~85     !7, $84
        166      > JMPNZ                                                    ~85, ->161
   69   167    >   INIT_FCALL                                               'microtime'
        168        SEND_VAL                                                 <true>
        169        DO_ICALL                                         $86     
        170        ASSIGN                                                   !5, $86
   70   171        INIT_FCALL                                               'printf'
        172        SEND_VAL                                                 'do+while+next+%25d+iterations+in+%25f+sec'
        173        SEND_VAR                                                 !1
        174        SUB                                              ~88     !5, !2
        175        SEND_VAL                                                 ~88
        176        DO_ICALL                                                 
   71   177        ECHO                                                     '%0A'
   73   178        INIT_FCALL                                               'range'
        179        SEND_VAL                                                 1
        180        SEND_VAL                                                 10000
        181        DO_ICALL                                         $90     
        182        ASSIGN                                                   !0, $90
   74   183        ASSIGN                                                   !1, 0
   75   184        INIT_FCALL                                               'microtime'
        185        SEND_VAL                                                 <true>
        186        DO_ICALL                                         $93     
        187        ASSIGN                                                   !2, $93
   76   188      > JMP                                                      ->193
   77   189    >   PRE_INC                                                  !1
   78   190        INIT_FCALL                                               'array_shift'
        191        SEND_REF                                                 !0
        192        DO_ICALL                                                 
   76   193    > > JMPNZ                                                    !0, ->189
   80   194    >   INIT_FCALL                                               'microtime'
        195        SEND_VAL                                                 <true>
        196        DO_ICALL                                         $97     
        197        ASSIGN                                                   !5, $97
   81   198        INIT_FCALL                                               'printf'
        199        SEND_VAL                                                 'while+array_shift+%25d+iterations+in%3A+%25f+sec'
        200        SEND_VAR                                                 !1
        201        SUB                                              ~99     !5, !2
        202        SEND_VAL                                                 ~99
        203        DO_ICALL                                                 
   82   204        ECHO                                                     '%0A'
   84   205        INIT_FCALL                                               'range'
        206        SEND_VAL                                                 1
        207        SEND_VAL                                                 10000
        208        DO_ICALL                                         $101    
        209        ASSIGN                                                   !0, $101
   85   210        ASSIGN                                                   !1, 0
   86   211        INIT_FCALL                                               'microtime'
        212        SEND_VAL                                                 <true>
        213        DO_ICALL                                         $104    
        214        ASSIGN                                                   !2, $104
   87   215        INIT_FCALL                                               'array_reverse'
        216        SEND_VAR                                                 !0
        217        DO_ICALL                                         $106    
        218        ASSIGN                                                   !0, $106
   88   219      > JMP                                                      ->224
   89   220    >   PRE_INC                                                  !1
   90   221        INIT_FCALL                                               'array_pop'
        222        SEND_REF                                                 !0
        223        DO_ICALL                                                 
   88   224    > > JMPNZ                                                    !0, ->220
   92   225    >   INIT_FCALL                                               'microtime'
        226        SEND_VAL                                                 <true>
        227        DO_ICALL                                         $110    
        228        ASSIGN                                                   !5, $110
   93   229        INIT_FCALL                                               'printf'
        230        SEND_VAL                                                 'while+array_pop+%25d+iterations+in%3A+%25f+sec'
        231        SEND_VAR                                                 !1
        232        SUB                                              ~112    !5, !2
        233        SEND_VAL                                                 ~112
        234        DO_ICALL                                                 
   94   235        ECHO                                                     '%0A'
   95   236      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.59 ms | 1416 KiB | 31 Q