3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = '#^/(?<owner>[^/]+)/(?<tournament>[^/]+)/(?<league>[^/]+)/(?<team1>[^/\-]+)\-(?<team1_number>\d+)_(?<team2>[^_\-]+)\-(?<team2_number>\d+)(?:\.(?<_format>html|xml|json))?$#s'; // 0.0165 ms avg $optRegex = '#^/(?<owner>[^/]++)/(?<tournament>[^/]++)/(?<league>[^/]++)/(?<team1>[^/\-]++)\-(?<team1_number>\d++)_(?<team2>[^_\-]++)\-(?<team2_number>\d++)(?:\.(?<_format>html|xml|json))?$#s'; // 0.02 ms avg // only needs 82.5% of the time $totaltime = 0; $matches = array(); for ($i = 0; $i < 1000; $i++) { $t = microtime(true); preg_match($regex, '/username/my-tournament', $matches); preg_match($regex, '/username/my-tournament/premier-league', $matches); preg_match($regex, '/username/my-tournament/premier-league/matches', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-A_CBA-B', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-1_CBA-2.pdf', $matches); preg_match($regex, '/username/my-tournament/premier-league/ABC-1_CBA-2', $matches); $time = ((microtime(true) - $t) * 1000); $totaltime += $time; } echo sprintf('%.4f ms avg', $totaltime / 1000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 6
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 6
Branch analysis from position: 50
Branch analysis from position: 6
filename:       /in/Y90TD
function name:  (null)
number of ops:  57
compiled vars:  !0 = $regex, !1 = $optRegex, !2 = $totaltime, !3 = $matches, !4 = $i, !5 = $t, !6 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%23%5E%2F%28%3F%3Cowner%3E%5B%5E%2F%5D%2B%29%2F%28%3F%3Ctournament%3E%5B%5E%2F%5D%2B%29%2F%28%3F%3Cleague%3E%5B%5E%2F%5D%2B%29%2F%28%3F%3Cteam1%3E%5B%5E%2F%5C-%5D%2B%29%5C-%28%3F%3Cteam1_number%3E%5Cd%2B%29_%28%3F%3Cteam2%3E%5B%5E_%5C-%5D%2B%29%5C-%28%3F%3Cteam2_number%3E%5Cd%2B%29%28%3F%3A%5C.%28%3F%3C_format%3Ehtml%7Cxml%7Cjson%29%29%3F%24%23s'
    7     1        ASSIGN                                                   !1, '%23%5E%2F%28%3F%3Cowner%3E%5B%5E%2F%5D%2B%2B%29%2F%28%3F%3Ctournament%3E%5B%5E%2F%5D%2B%2B%29%2F%28%3F%3Cleague%3E%5B%5E%2F%5D%2B%2B%29%2F%28%3F%3Cteam1%3E%5B%5E%2F%5C-%5D%2B%2B%29%5C-%28%3F%3Cteam1_number%3E%5Cd%2B%2B%29_%28%3F%3Cteam2%3E%5B%5E_%5C-%5D%2B%2B%29%5C-%28%3F%3Cteam2_number%3E%5Cd%2B%2B%29%28%3F%3A%5C.%28%3F%3C_format%3Ehtml%7Cxml%7Cjson%29%29%3F%24%23s'
   11     2        ASSIGN                                                   !2, 0
   12     3        ASSIGN                                                   !3, <array>
   13     4        ASSIGN                                                   !4, 0
          5      > JMP                                                      ->48
   14     6    >   INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $12     
          9        ASSIGN                                                   !5, $12
   16    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '%2Fusername%2Fmy-tournament'
         13        SEND_REF                                                 !3
         14        DO_ICALL                                                 
   17    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 '%2Fusername%2Fmy-tournament%2Fpremier-league'
         18        SEND_REF                                                 !3
         19        DO_ICALL                                                 
   18    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 '%2Fusername%2Fmy-tournament%2Fpremier-league%2Fmatches'
         23        SEND_REF                                                 !3
         24        DO_ICALL                                                 
   19    25        INIT_FCALL                                               'preg_match'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 '%2Fusername%2Fmy-tournament%2Fpremier-league%2FABC-A_CBA-B'
         28        SEND_REF                                                 !3
         29        DO_ICALL                                                 
   20    30        INIT_FCALL                                               'preg_match'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 '%2Fusername%2Fmy-tournament%2Fpremier-league%2FABC-1_CBA-2.pdf'
         33        SEND_REF                                                 !3
         34        DO_ICALL                                                 
   21    35        INIT_FCALL                                               'preg_match'
         36        SEND_VAR                                                 !0
         37        SEND_VAL                                                 '%2Fusername%2Fmy-tournament%2Fpremier-league%2FABC-1_CBA-2'
         38        SEND_REF                                                 !3
         39        DO_ICALL                                                 
   23    40        INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $20     
         43        SUB                                              ~21     $20, !5
         44        MUL                                              ~22     ~21, 1000
         45        ASSIGN                                                   !6, ~22
   24    46        ASSIGN_OP                                     1          !2, !6
   13    47        PRE_INC                                                  !4
         48    >   IS_SMALLER                                               !4, 1000
         49      > JMPNZ                                                    ~26, ->6
   27    50    >   INIT_FCALL                                               'sprintf'
         51        SEND_VAL                                                 '%25.4f+ms+avg'
         52        DIV                                              ~27     !2, 1000
         53        SEND_VAL                                                 ~27
         54        DO_ICALL                                         $28     
         55        ECHO                                                     $28
         56      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.64 ms | 1400 KiB | 19 Q