3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = array(); for($i = 0; $i < 10000; $i++) $items[] = (string)rand(10000000, 99999999); $time_start = microtime(true); $cnt = count($items); for($i = 0; $i < $cnt; $i++) { } $time_end = microtime(true); $for_time = $time_end - $time_start; $time_start = microtime(true); for($i = 0; $i < count($items); $i++) { } $time_end = microtime(true); $for_count_time = $time_end - $time_start; $time_start = microtime(true); foreach($items as $element) { } $time_end = microtime(true); $foreach_time = $time_end - $time_start; echo "For: " . number_format($for_time * 1000, 2) . "ms\n"; echo "For with count(): " . number_format($for_count_time * 1000, 2) . "ms\n"; echo "Foreach: " . number_format($foreach_time * 1000, 2) . "ms\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 21
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 36
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 53
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 53
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 36
Branch analysis from position: 40
Branch analysis from position: 36
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 21
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
Branch analysis from position: 3
filename:       /in/QQ4FV
function name:  (null)
number of ops:  85
compiled vars:  !0 = $items, !1 = $i, !2 = $time_start, !3 = $cnt, !4 = $time_end, !5 = $for_time, !6 = $for_count_time, !7 = $element, !8 = $foreach_time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->11
          3    >   INIT_FCALL                                               'rand'
          4        SEND_VAL                                                 10000000
          5        SEND_VAL                                                 99999999
          6        DO_ICALL                                         $12     
          7        CAST                                          6  ~13     $12
          8        ASSIGN_DIM                                               !0
          9        OP_DATA                                                  ~13
         10        PRE_INC                                                  !1
         11    >   IS_SMALLER                                               !1, 10000
         12      > JMPNZ                                                    ~15, ->3
    7    13    >   INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !2, $16
    9    17        COUNT                                            ~18     !0
         18        ASSIGN                                                   !3, ~18
   10    19        ASSIGN                                                   !1, 0
         20      > JMP                                                      ->22
         21    >   PRE_INC                                                  !1
         22    >   IS_SMALLER                                               !1, !3
         23      > JMPNZ                                                    ~22, ->21
   11    24    >   INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $23     
         27        ASSIGN                                                   !4, $23
   12    28        SUB                                              ~25     !4, !2
         29        ASSIGN                                                   !5, ~25
   15    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $27     
         33        ASSIGN                                                   !2, $27
   16    34        ASSIGN                                                   !1, 0
         35      > JMP                                                      ->37
         36    >   PRE_INC                                                  !1
         37    >   COUNT                                            ~31     !0
         38        IS_SMALLER                                               !1, ~31
         39      > JMPNZ                                                    ~32, ->36
   17    40    >   INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $33     
         43        ASSIGN                                                   !4, $33
   18    44        SUB                                              ~35     !4, !2
         45        ASSIGN                                                   !6, ~35
   21    46        INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $37     
         49        ASSIGN                                                   !2, $37
   22    50      > FE_RESET_R                                       $39     !0, ->53
         51    > > FE_FETCH_R                                               $39, !7, ->53
         52    > > JMP                                                      ->51
         53    >   FE_FREE                                                  $39
   23    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $40     
         57        ASSIGN                                                   !4, $40
   24    58        SUB                                              ~42     !4, !2
         59        ASSIGN                                                   !8, ~42
   26    60        INIT_FCALL                                               'number_format'
         61        MUL                                              ~44     !5, 1000
         62        SEND_VAL                                                 ~44
         63        SEND_VAL                                                 2
         64        DO_ICALL                                         $45     
         65        CONCAT                                           ~46     'For%3A+', $45
         66        CONCAT                                           ~47     ~46, 'ms%0A'
         67        ECHO                                                     ~47
   27    68        INIT_FCALL                                               'number_format'
         69        MUL                                              ~48     !6, 1000
         70        SEND_VAL                                                 ~48
         71        SEND_VAL                                                 2
         72        DO_ICALL                                         $49     
         73        CONCAT                                           ~50     'For+with+count%28%29%3A+', $49
         74        CONCAT                                           ~51     ~50, 'ms%0A'
         75        ECHO                                                     ~51
   28    76        INIT_FCALL                                               'number_format'
         77        MUL                                              ~52     !8, 1000
         78        SEND_VAL                                                 ~52
         79        SEND_VAL                                                 2
         80        DO_ICALL                                         $53     
         81        CONCAT                                           ~54     'Foreach%3A+', $53
         82        CONCAT                                           ~55     ~54, 'ms%0A'
         83        ECHO                                                     ~55
         84      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.52 ms | 1009 KiB | 16 Q