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/a3Jn4
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
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10000
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !0, $8
    4     5        ASSIGN                                                   !1, 0
    5     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !2, $11
    6    10        COUNT                                            ~13     !0
         11        ASSIGN                                                   !3, ~13
    7    12        ASSIGN                                                   !4, 0
    8    13      > JMP                                                      ->16
    9    14    >   PRE_INC                                                  !1
   10    15        PRE_INC                                                  !4
    8    16    >   IS_SMALLER                                               !4, !3
         17      > JMPNZ                                                    ~18, ->14
   12    18    >   INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $19     
         21        ASSIGN                                                   !5, $19
   13    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                                                 
   14    28        ECHO                                                     '%0A'
   16    29        INIT_FCALL                                               'range'
         30        SEND_VAL                                                 1
         31        SEND_VAL                                                 10000
         32        DO_ICALL                                         $23     
         33        ASSIGN                                                   !0, $23
   17    34        ASSIGN                                                   !1, 0
   18    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $26     
         38        ASSIGN                                                   !2, $26
   19    39        COUNT                                            ~28     !0
         40        ASSIGN                                                   !3, ~28
   20    41        ASSIGN                                                   !4, 0
         42      > JMP                                                      ->45
   21    43    >   PRE_INC                                                  !1
   20    44        PRE_INC                                                  !4
         45    >   IS_SMALLER                                               !4, !3
         46      > JMPNZ                                                    ~33, ->43
   23    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $34     
         50        ASSIGN                                                   !5, $34
   24    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                                                 
   25    57        ECHO                                                     '%0A'
   27    58        INIT_FCALL                                               'range'
         59        SEND_VAL                                                 1
         60        SEND_VAL                                                 10000
         61        DO_ICALL                                         $38     
         62        ASSIGN                                                   !0, $38
   28    63        ASSIGN                                                   !1, 0
   29    64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $41     
         67        ASSIGN                                                   !2, $41
   30    68      > FE_RESET_R                                       $43     !0, ->72
         69    > > FE_FETCH_R                                               $43, !6, ->72
   31    70    >   PRE_INC                                                  !1
   30    71      > JMP                                                      ->69
         72    >   FE_FREE                                                  $43
   33    73        INIT_FCALL                                               'microtime'
         74        SEND_VAL                                                 <true>
         75        DO_ICALL                                         $45     
         76        ASSIGN                                                   !5, $45
   34    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                                                 
   35    83        ECHO                                                     '%0A'
   38    84        INIT_FCALL                                               'range'
         85        SEND_VAL                                                 1
         86        SEND_VAL                                                 10000
         87        DO_ICALL                                         $49     
         88        ASSIGN                                                   !0, $49
   39    89        ASSIGN                                                   !1, 0
   40    90        INIT_FCALL                                               'microtime'
         91        SEND_VAL                                                 <true>
         92        DO_ICALL                                         $52     
         93        ASSIGN                                                   !2, $52
   41    94        INIT_FCALL                                               'reset'
         95        SEND_REF                                                 !0
         96        DO_ICALL                                         $54     
         97        ASSIGN                                                   !7, $54
   42    98      > JMP                                                      ->104
   43    99    >   PRE_INC                                                  !1
   44   100        INIT_FCALL                                               'next'
        101        SEND_REF                                                 !0
        102        DO_ICALL                                         $57     
        103        ASSIGN                                                   !7, $57
   42   104    > > JMPNZ                                                    !7, ->99
   46   105    >   INIT_FCALL                                               'microtime'
        106        SEND_VAL                                                 <true>
        107        DO_ICALL                                         $59     
        108        ASSIGN                                                   !5, $59
   47   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                                                 
   48   115        ECHO                                                     '%0A'
   50   116        INIT_FCALL                                               'range'
        117        SEND_VAL                                                 1
        118        SEND_VAL                                                 10000
        119        DO_ICALL                                         $63     
        120        ASSIGN                                                   !0, $63
   51   121        ASSIGN                                                   !1, 0
   52   122        INIT_FCALL                                               'microtime'
        123        SEND_VAL                                                 <true>
        124        DO_ICALL                                         $66     
        125        ASSIGN                                                   !2, $66
   53   126      > JMP                                                      ->131
   54   127    >   PRE_INC                                                  !1
   55   128        INIT_FCALL                                               'next'
        129        SEND_REF                                                 !0
        130        DO_ICALL                                                 
   53   131    >   INIT_FCALL                                               'current'
        132        SEND_VAR                                                 !0
        133        DO_ICALL                                         $70     
        134        ASSIGN                                           ~71     !6, $70
        135      > JMPNZ                                                    ~71, ->127
   57   136    >   INIT_FCALL                                               'microtime'
        137        SEND_VAL                                                 <true>
        138        DO_ICALL                                         $72     
        139        ASSIGN                                                   !5, $72
   58   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                                                 
   59   146        ECHO                                                     '%0A'
   61   147        INIT_FCALL                                               'range'
        148        SEND_VAL                                                 1
        149        SEND_VAL                                                 10000
        150        DO_ICALL                                         $76     
        151        ASSIGN                                                   !0, $76
   62   152        ASSIGN                                                   !1, 0
   63   153        INIT_FCALL                                               'microtime'
        154        SEND_VAL                                                 <true>
        155        DO_ICALL                                         $79     
        156        ASSIGN                                                   !2, $79
   64   157        INIT_FCALL                                               'current'
        158        SEND_VAR                                                 !0
        159        DO_ICALL                                         $81     
        160        ASSIGN                                                   !7, $81
   66   161    >   PRE_INC                                                  !1
   67   162        INIT_FCALL                                               'next'
        163        SEND_REF                                                 !0
        164        DO_ICALL                                         $84     
        165        ASSIGN                                           ~85     !7, $84
        166      > JMPNZ                                                    ~85, ->161
   68   167    >   INIT_FCALL                                               'microtime'
        168        SEND_VAL                                                 <true>
        169        DO_ICALL                                         $86     
        170        ASSIGN                                                   !5, $86
   69   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                                                 
   70   177        ECHO                                                     '%0A'
   72   178        INIT_FCALL                                               'range'
        179        SEND_VAL                                                 1
        180        SEND_VAL                                                 10000
        181        DO_ICALL                                         $90     
        182        ASSIGN                                                   !0, $90
   73   183        ASSIGN                                                   !1, 0
   74   184        INIT_FCALL                                               'microtime'
        185        SEND_VAL                                                 <true>
        186        DO_ICALL                                         $93     
        187        ASSIGN                                                   !2, $93
   75   188      > JMP                                                      ->193
   76   189    >   PRE_INC                                                  !1
   77   190        INIT_FCALL                                               'array_shift'
        191        SEND_REF                                                 !0
        192        DO_ICALL                                                 
   75   193    > > JMPNZ                                                    !0, ->189
   79   194    >   INIT_FCALL                                               'microtime'
        195        SEND_VAL                                                 <true>
        196        DO_ICALL                                         $97     
        197        ASSIGN                                                   !5, $97
   80   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                                                 
   81   204        ECHO                                                     '%0A'
   83   205        INIT_FCALL                                               'range'
        206        SEND_VAL                                                 1
        207        SEND_VAL                                                 10000
        208        DO_ICALL                                         $101    
        209        ASSIGN                                                   !0, $101
   84   210        ASSIGN                                                   !1, 0
   85   211        INIT_FCALL                                               'microtime'
        212        SEND_VAL                                                 <true>
        213        DO_ICALL                                         $104    
        214        ASSIGN                                                   !2, $104
   86   215        INIT_FCALL                                               'array_reverse'
        216        SEND_VAR                                                 !0
        217        DO_ICALL                                         $106    
        218        ASSIGN                                                   !0, $106
   87   219      > JMP                                                      ->224
   88   220    >   PRE_INC                                                  !1
   89   221        INIT_FCALL                                               'array_pop'
        222        SEND_REF                                                 !0
        223        DO_ICALL                                                 
   87   224    > > JMPNZ                                                    !0, ->220
   91   225    >   INIT_FCALL                                               'microtime'
        226        SEND_VAL                                                 <true>
        227        DO_ICALL                                         $110    
        228        ASSIGN                                                   !5, $110
   92   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                                                 
   93   235        ECHO                                                     '%0A'
        236      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.35 ms | 1489 KiB | 22 Q