3v4l.org

run code in 300+ PHP versions simultaneously
<?php $time = microtime(true); for ($i = 0; $i < 1000000; $i++) { preg_match('/^(http|https)?:?\/\//', 'https://stackoverflow.com/questions/20248666/in-this-case-which-is-better-in-matching-regular-expression-or-parse-url'); } echo number_format(microtime(true) - $time, 10), "\n"; $time = microtime(true); for ($i = 0; $i < 1000000; $i++) { strpos('https://stackoverflow.com/questions/20248666/in-this-case-which-is-better-in-matching-regular-expression-or-parse-url', 'https://') === 0 || strpos('https://stackoverflow.com/questions/20248666/in-this-case-which-is-better-in-matching-regular-expression-or-parse-url', 'http://') === 0 || strpos('https://stackoverflow.com/questions/20248666/in-this-case-which-is-better-in-matching-regular-expression-or-parse-url', '//'); } echo number_format(microtime(true) - $time, 10);
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 = 6
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 29
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 47) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
2 jumps found. (Code = 47) Position 1 = 42, Position 2 = 47
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 29
Branch analysis from position: 50
Branch analysis from position: 29
Branch analysis from position: 47
Branch analysis from position: 41
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Branch analysis from position: 6
filename:       /in/ioiFVo
function name:  (null)
number of ops:  60
compiled vars:  !0 = $time, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
    4     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->11
    5     6    >   INIT_FCALL                                               'preg_match'
          7        SEND_VAL                                                 '%2F%5E%28http%7Chttps%29%3F%3A%3F%5C%2F%5C%2F%2F'
          8        SEND_VAL                                                 'https%3A%2F%2Fstackoverflow.com%2Fquestions%2F20248666%2Fin-this-case-which-is-better-in-matching-regular-expression-or-parse-url'
          9        DO_ICALL                                                 
    4    10        PRE_INC                                                  !1
         11    >   IS_SMALLER                                               !1, 1000000
         12      > JMPNZ                                                    ~7, ->6
    8    13    >   INIT_FCALL                                               'number_format'
         14        INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $8      
         17        SUB                                              ~9      $8, !0
         18        SEND_VAL                                                 ~9
         19        SEND_VAL                                                 10
         20        DO_ICALL                                         $10     
         21        ECHO                                                     $10
         22        ECHO                                                     '%0A'
   11    23        INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $11     
         26        ASSIGN                                                   !0, $11
   12    27        ASSIGN                                                   !1, 0
         28      > JMP                                                      ->48
   13    29    >   INIT_FCALL                                               'strpos'
         30        SEND_VAL                                                 'https%3A%2F%2Fstackoverflow.com%2Fquestions%2F20248666%2Fin-this-case-which-is-better-in-matching-regular-expression-or-parse-url'
         31        SEND_VAL                                                 'https%3A%2F%2F'
         32        DO_ICALL                                         $14     
         33        IS_IDENTICAL                                     ~15     $14, 0
         34      > JMPNZ_EX                                         ~15     ~15, ->41
   14    35    >   INIT_FCALL                                               'strpos'
         36        SEND_VAL                                                 'https%3A%2F%2Fstackoverflow.com%2Fquestions%2F20248666%2Fin-this-case-which-is-better-in-matching-regular-expression-or-parse-url'
         37        SEND_VAL                                                 'http%3A%2F%2F'
         38        DO_ICALL                                         $16     
         39        IS_IDENTICAL                                     ~17     $16, 0
         40        BOOL                                             ~15     ~17
         41    > > JMPNZ_EX                                         ~15     ~15, ->47
   15    42    >   INIT_FCALL                                               'strpos'
         43        SEND_VAL                                                 'https%3A%2F%2Fstackoverflow.com%2Fquestions%2F20248666%2Fin-this-case-which-is-better-in-matching-regular-expression-or-parse-url'
         44        SEND_VAL                                                 '%2F%2F'
         45        DO_ICALL                                         $18     
         46        BOOL                                             ~15     $18
   12    47    >   PRE_INC                                                  !1
         48    >   IS_SMALLER                                               !1, 1000000
         49      > JMPNZ                                                    ~20, ->29
   18    50    >   INIT_FCALL                                               'number_format'
         51        INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $21     
         54        SUB                                              ~22     $21, !0
         55        SEND_VAL                                                 ~22
         56        SEND_VAL                                                 10
         57        DO_ICALL                                         $23     
         58        ECHO                                                     $23
         59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.05 ms | 1008 KiB | 17 Q