3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ''; for( $i = 0; $i <= 100; $i++ ) { $str .= str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); } $start = microtime(true); for( $i = 0; $i<800000; $i++ ) { substr_count( 'foobar', $str ); } echo "count: " . (microtime(true)-$start) . PHP_EOL; $start = microtime(true); for( $i = 0; $i<800000; $i++ ) { preg_match_all( '/foobar/', $str ); } echo "rcount: " . (microtime(true)-$start) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 36
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 36
Branch analysis from position: 43
Branch analysis from position: 36
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
Branch analysis from position: 16
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/S6IGP
function name:  (null)
number of ops:  51
compiled vars:  !0 = $str, !1 = $i, !2 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, ''
    4     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->8
    5     3    >   INIT_FCALL                                               'str_shuffle'
          4        SEND_VAL                                                 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
          5        DO_ICALL                                         $5      
          6        ASSIGN_OP                                     8          !0, $5
    4     7        PRE_INC                                                  !1
          8    >   IS_SMALLER_OR_EQUAL                                      !1, 100
          9      > JMPNZ                                                    ~8, ->3
    8    10    >   INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !2, $9
    9    14        ASSIGN                                                   !1, 0
         15      > JMP                                                      ->21
   10    16    >   INIT_FCALL                                               'substr_count'
         17        SEND_VAL                                                 'foobar'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
    9    20        PRE_INC                                                  !1
         21    >   IS_SMALLER                                               !1, 800000
         22      > JMPNZ                                                    ~14, ->16
   12    23    >   INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $15     
         26        SUB                                              ~16     $15, !2
         27        CONCAT                                           ~17     'count%3A+', ~16
         28        CONCAT                                           ~18     ~17, '%0A'
         29        ECHO                                                     ~18
   13    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $19     
         33        ASSIGN                                                   !2, $19
   14    34        ASSIGN                                                   !1, 0
         35      > JMP                                                      ->41
   15    36    >   INIT_FCALL                                               'preg_match_all'
         37        SEND_VAL                                                 '%2Ffoobar%2F'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                                 
   14    40        PRE_INC                                                  !1
         41    >   IS_SMALLER                                               !1, 800000
         42      > JMPNZ                                                    ~24, ->36
   17    43    >   INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $25     
         46        SUB                                              ~26     $25, !2
         47        CONCAT                                           ~27     'rcount%3A+', ~26
         48        CONCAT                                           ~28     ~27, '%0A'
         49        ECHO                                                     ~28
   18    50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.26 ms | 1400 KiB | 21 Q