3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); $strings = []; for ($i = 0; $i < 100000; $i ++) { $strings[] = random_bytes(10); } $start = microtime(true); $matches = 0; foreach ($strings as $string) { if ($string[0] === 'a') { $matches ++; } } var_dump($matches . chr(10)); var_dump($time_elapsed_secs = microtime(true) - $start . chr(10)); $start = microtime(true); $matches = 0; foreach ($strings as $string) { if (str_starts_with($string, 'a')) { $matches ++; } } var_dump($matches . chr(10)); var_dump($time_elapsed_secs = microtime(true) - $start . chr(10));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 22
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 47
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 23
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/07iHL
function name:  (null)
number of ops:  63
compiled vars:  !0 = $strings, !1 = $i, !2 = $start, !3 = $matches, !4 = $string, !5 = $time_elapsed_secs
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, <array>
    6     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->9
    7     3    >   INIT_FCALL                                                   'random_bytes'
          4        SEND_VAL                                                     10
          5        DO_ICALL                                             $9      
          6        ASSIGN_DIM                                                   !0
          7        OP_DATA                                                      $9
    6     8        PRE_INC                                                      !1
          9    >   IS_SMALLER                                                   !1, 100000
         10      > JMPNZ                                                        ~11, ->3
   10    11    >   INIT_FCALL                                                   'microtime'
         12        SEND_VAL                                                     <true>
         13        DO_ICALL                                             $12     
         14        ASSIGN                                                       !2, $12
   11    15        ASSIGN                                                       !3, 0
   12    16      > FE_RESET_R                                           $15     !0, ->23
         17    > > FE_FETCH_R                                                   $15, !4, ->23
   13    18    >   FETCH_DIM_R                                          ~16     !4, 0
         19        IS_IDENTICAL                                                 ~16, 'a'
         20      > JMPZ                                                         ~17, ->22
   14    21    >   PRE_INC                                                      !3
   12    22    > > JMP                                                          ->17
         23    >   FE_FREE                                                      $15
   17    24        INIT_FCALL                                                   'var_dump'
         25        CONCAT                                               ~19     !3, '%0A'
         26        SEND_VAL                                                     ~19
         27        DO_ICALL                                                     
   18    28        INIT_FCALL                                                   'var_dump'
         29        INIT_FCALL                                                   'microtime'
         30        SEND_VAL                                                     <true>
         31        DO_ICALL                                             $21     
         32        SUB                                                  ~22     $21, !2
         33        CONCAT                                               ~23     ~22, '%0A'
         34        ASSIGN                                               ~24     !5, ~23
         35        SEND_VAL                                                     ~24
         36        DO_ICALL                                                     
   20    37        INIT_FCALL                                                   'microtime'
         38        SEND_VAL                                                     <true>
         39        DO_ICALL                                             $26     
         40        ASSIGN                                                       !2, $26
   21    41        ASSIGN                                                       !3, 0
   22    42      > FE_RESET_R                                           $29     !0, ->48
         43    > > FE_FETCH_R                                                   $29, !4, ->48
   23    44    >   FRAMELESS_ICALL_2                str_starts_with      ~30     !4, 'a'
         45      > JMPZ                                                         ~30, ->47
   24    46    >   PRE_INC                                                      !3
   22    47    > > JMP                                                          ->43
         48    >   FE_FREE                                                      $29
   27    49        INIT_FCALL                                                   'var_dump'
         50        CONCAT                                               ~32     !3, '%0A'
         51        SEND_VAL                                                     ~32
         52        DO_ICALL                                                     
   28    53        INIT_FCALL                                                   'var_dump'
         54        INIT_FCALL                                                   'microtime'
         55        SEND_VAL                                                     <true>
         56        DO_ICALL                                             $34     
         57        SUB                                                  ~35     $34, !2
         58        CONCAT                                               ~36     ~35, '%0A'
         59        ASSIGN                                               ~37     !5, ~36
         60        SEND_VAL                                                     ~37
         61        DO_ICALL                                                     
         62      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.49 ms | 501 KiB | 14 Q