3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Run pinned to specific CPU core: * taskset -c 3 php perf-regex-strings.php */ $pattern = '/[&]/u'; // This will not produce any match in test subject. $textA = 'weengahhoghecho1eeSheeG5el9cie5b'; $textB = sprintf('%s', 'weengahhoghecho1eeSheeG5el9cie5b'); $textC = 'weengahhoghecho1eeSheeG5el9cie5' . 'b'; $textD_1 = 'weengahhoghecho1eeSheeG5el9cie5'; $textD = $textD_1 . 'b'; $tests = ['A', 'A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']; foreach ($tests as $test) { $subject = ''; switch ($test) { case 'A': $subject = $textA; break; case 'B': $subject = $textB; break; case 'C': $subject = $textC; break; case 'D': $subject = $textD; break; } $start = microtime(true); for ($i = 0; $i < 1000000; $i++) { preg_match($pattern, $subject); } $diff = sprintf('%.6f sec.', microtime(true) - $start); echo "Execution time $test: $diff\n"; gc_collect_cycles(); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 59
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 59
Branch analysis from position: 11
6 jumps found. (Code = 188) Position 1 = 22, Position 2 = 24, Position 3 = 26, Position 4 = 28, Position 5 = 30, Position 6 = 13
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 36
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 36
Branch analysis from position: 41
Branch analysis from position: 36
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 30
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 28
Branch analysis from position: 26
Branch analysis from position: 24
Branch analysis from position: 22
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
filename:       /in/uFPrD
function name:  (null)
number of ops:  61
compiled vars:  !0 = $pattern, !1 = $textA, !2 = $textB, !3 = $textC, !4 = $textD_1, !5 = $textD, !6 = $tests, !7 = $test, !8 = $subject, !9 = $start, !10 = $i, !11 = $diff
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                       !0, '%2F%5B%26%5D%2Fu'
   10     1        ASSIGN                                                       !1, 'weengahhoghecho1eeSheeG5el9cie5b'
   11     2        NOP                                                          
          3        ASSIGN                                                       !2, 'weengahhoghecho1eeSheeG5el9cie5b'
   12     4        ASSIGN                                                       !3, 'weengahhoghecho1eeSheeG5el9cie5b'
   14     5        ASSIGN                                                       !4, 'weengahhoghecho1eeSheeG5el9cie5'
   15     6        CONCAT                                               ~17     !4, 'b'
          7        ASSIGN                                                       !5, ~17
   17     8        ASSIGN                                                       !6, <array>
   19     9      > FE_RESET_R                                           $20     !6, ->59
         10    > > FE_FETCH_R                                                   $20, !7, ->59
   20    11    >   ASSIGN                                                       !8, ''
   21    12      > SWITCH_STRING                                                !7, [ 'A':->22, 'B':->24, 'C':->26, 'D':->28, ], ->30
   22    13    >   IS_EQUAL                                                     !7, 'A'
         14      > JMPNZ                                                        ~22, ->22
   25    15    >   IS_EQUAL                                                     !7, 'B'
         16      > JMPNZ                                                        ~22, ->24
   28    17    >   IS_EQUAL                                                     !7, 'C'
         18      > JMPNZ                                                        ~22, ->26
   31    19    >   IS_EQUAL                                                     !7, 'D'
         20      > JMPNZ                                                        ~22, ->28
         21    > > JMP                                                          ->30
   23    22    >   ASSIGN                                                       !8, !1
   24    23      > JMP                                                          ->30
   26    24    >   ASSIGN                                                       !8, !2
   27    25      > JMP                                                          ->30
   29    26    >   ASSIGN                                                       !8, !3
   30    27      > JMP                                                          ->30
   32    28    >   ASSIGN                                                       !8, !5
   33    29      > JMP                                                          ->30
   36    30    >   INIT_FCALL                                                   'microtime'
         31        SEND_VAL                                                     <true>
         32        DO_ICALL                                             $27     
         33        ASSIGN                                                       !9, $27
   38    34        ASSIGN                                                       !10, 0
         35      > JMP                                                          ->39
   39    36    >   FRAMELESS_ICALL_2                preg_match          ~30     !0, !8
         37        FREE                                                         ~30
   38    38        PRE_INC                                                      !10
         39    >   IS_SMALLER                                                   !10, 1000000
         40      > JMPNZ                                                        ~32, ->36
   42    41    >   INIT_FCALL                                                   'sprintf'
         42        SEND_VAL                                                     '%25.6f+sec.'
         43        INIT_FCALL                                                   'microtime'
         44        SEND_VAL                                                     <true>
         45        DO_ICALL                                             $33     
         46        SUB                                                  ~34     $33, !9
         47        SEND_VAL                                                     ~34
         48        DO_ICALL                                             $35     
         49        ASSIGN                                                       !11, $35
   43    50        ROPE_INIT                                         5  ~38     'Execution+time+'
         51        ROPE_ADD                                          1  ~38     ~38, !7
         52        ROPE_ADD                                          2  ~38     ~38, '%3A+'
         53        ROPE_ADD                                          3  ~38     ~38, !11
         54        ROPE_END                                          4  ~37     ~38, '%0A'
         55        ECHO                                                         ~37
   45    56        INIT_FCALL                                                   'gc_collect_cycles'
         57        DO_ICALL                                                     
   19    58      > JMP                                                          ->10
         59    >   FE_FREE                                                      $20
   46    60      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.89 ms | 485 KiB | 10 Q