3v4l.org

run code in 500+ PHP versions simultaneously
<?php function str_contains_eval( $show = '' ) { if ( str_contains( $show, 'url' ) || str_contains( $show, 'directory' ) || str_contains( $show, 'home' ) ) {} } function preg_match_eval( $show = '' ) { if ( preg_match( '/url|directory|home/', $show ) ) {} } $its = 1e3; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = str_contains_eval( 'blogname' ); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = preg_match_eval( 'blogname' ); echo (hrtime(true)-$t)/1e9,"s\n"; echo "\n=== Warmed up ===\n\n"; $its = 1e5; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = str_contains_eval( 'blogname' ); echo 'str_contains chain: ', $a=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = preg_match_eval( 'blogname' ); echo 'preg_match : ', $b=(hrtime(true)-$t)/1e9,"s\n"; echo 'preg_match is ', number_format((($a-$b)/$a) * 100, 2 ), "% faster than str_contains chain\n";
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 = 14, Position 2 = 7
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 27
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 71
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 71
Branch analysis from position: 78
Branch analysis from position: 71
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
Branch analysis from position: 49
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 27
Branch analysis from position: 34
Branch analysis from position: 27
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
Branch analysis from position: 7
filename:       /in/3AXAY
function name:  (null)
number of ops:  98
compiled vars:  !0 = $its, !1 = $t, !2 = $i, !3 = $z, !4 = $a, !5 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                       !0, 1000
   14     1        INIT_FCALL                                                   'hrtime'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                             $7      
          4        ASSIGN                                                       !1, $7
   15     5        ASSIGN                                                       !2, 0
          6      > JMP                                                          ->11
   16     7    >   INIT_FCALL                                                   'str_contains_eval'
          8        SEND_VAL                                                     'blogname'
          9        DO_FCALL                                          0  $10     
         10        ASSIGN                                                       !3, $10
   15    11    >   POST_INC                                             ~12     !2
         12        IS_SMALLER                                                   ~12, !0
         13      > JMPNZ                                                        ~13, ->7
   17    14    >   INIT_FCALL                                                   'hrtime'
         15        SEND_VAL                                                     <true>
         16        DO_ICALL                                             $14     
         17        SUB                                                  ~15     $14, !1
         18        DIV                                                  ~16     ~15, 1.0e+9
         19        ECHO                                                         ~16
         20        ECHO                                                         's%0A'
   19    21        INIT_FCALL                                                   'hrtime'
         22        SEND_VAL                                                     <true>
         23        DO_ICALL                                             $17     
         24        ASSIGN                                                       !1, $17
   20    25        ASSIGN                                                       !2, 0
         26      > JMP                                                          ->31
   21    27    >   INIT_FCALL                                                   'preg_match_eval'
         28        SEND_VAL                                                     'blogname'
         29        DO_FCALL                                          0  $20     
         30        ASSIGN                                                       !3, $20
   20    31    >   POST_INC                                             ~22     !2
         32        IS_SMALLER                                                   ~22, !0
         33      > JMPNZ                                                        ~23, ->27
   22    34    >   INIT_FCALL                                                   'hrtime'
         35        SEND_VAL                                                     <true>
         36        DO_ICALL                                             $24     
         37        SUB                                                  ~25     $24, !1
         38        DIV                                                  ~26     ~25, 1.0e+9
         39        ECHO                                                         ~26
         40        ECHO                                                         's%0A'
   24    41        ECHO                                                         '%0A%3D%3D%3D+Warmed+up+%3D%3D%3D%0A%0A'
   26    42        ASSIGN                                                       !0, 100000
   28    43        INIT_FCALL                                                   'hrtime'
         44        SEND_VAL                                                     <true>
         45        DO_ICALL                                             $28     
         46        ASSIGN                                                       !1, $28
   29    47        ASSIGN                                                       !2, 0
         48      > JMP                                                          ->53
   30    49    >   INIT_FCALL                                                   'str_contains_eval'
         50        SEND_VAL                                                     'blogname'
         51        DO_FCALL                                          0  $31     
         52        ASSIGN                                                       !3, $31
   29    53    >   POST_INC                                             ~33     !2
         54        IS_SMALLER                                                   ~33, !0
         55      > JMPNZ                                                        ~34, ->49
   31    56    >   ECHO                                                         'str_contains+chain%3A+'
         57        INIT_FCALL                                                   'hrtime'
         58        SEND_VAL                                                     <true>
         59        DO_ICALL                                             $35     
         60        SUB                                                  ~36     $35, !1
         61        DIV                                                  ~37     ~36, 1.0e+9
         62        ASSIGN                                               ~38     !4, ~37
         63        ECHO                                                         ~38
         64        ECHO                                                         's%0A'
   33    65        INIT_FCALL                                                   'hrtime'
         66        SEND_VAL                                                     <true>
         67        DO_ICALL                                             $39     
         68        ASSIGN                                                       !1, $39
   34    69        ASSIGN                                                       !2, 0
         70      > JMP                                                          ->75
   35    71    >   INIT_FCALL                                                   'preg_match_eval'
         72        SEND_VAL                                                     'blogname'
         73        DO_FCALL                                          0  $42     
         74        ASSIGN                                                       !3, $42
   34    75    >   POST_INC                                             ~44     !2
         76        IS_SMALLER                                                   ~44, !0
         77      > JMPNZ                                                        ~45, ->71
   36    78    >   ECHO                                                         'preg_match++++++++%3A+'
         79        INIT_FCALL                                                   'hrtime'
         80        SEND_VAL                                                     <true>
         81        DO_ICALL                                             $46     
         82        SUB                                                  ~47     $46, !1
         83        DIV                                                  ~48     ~47, 1.0e+9
         84        ASSIGN                                               ~49     !5, ~48
         85        ECHO                                                         ~49
         86        ECHO                                                         's%0A'
   38    87        ECHO                                                         'preg_match+is+'
         88        INIT_FCALL                                                   'number_format'
         89        SUB                                                  ~50     !4, !5
         90        DIV                                                  ~51     ~50, !4
         91        MUL                                                  ~52     ~51, 100
         92        SEND_VAL                                                     ~52
         93        SEND_VAL                                                     2
         94        DO_ICALL                                             $53     
         95        ECHO                                                         $53
         96        ECHO                                                         '%25+faster+than+str_contains+chain%0A'
         97      > RETURN                                                       1

Function str_contains_eval:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
Branch analysis from position: 8
Branch analysis from position: 5
filename:       /in/3AXAY
function name:  str_contains_eval
number of ops:  10
compiled vars:  !0 = $show
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                            !0      ''
    4     1        FRAMELESS_ICALL_2                str_contains        ~1      !0, 'url'
          2      > JMPNZ_EX                                             ~1      ~1, ->5
    5     3    >   FRAMELESS_ICALL_2                str_contains        ~2      !0, 'directory'
          4        BOOL                                                 ~1      ~2
          5    > > JMPNZ_EX                                             ~1      ~1, ->8
    6     6    >   FRAMELESS_ICALL_2                str_contains        ~3      !0, 'home'
          7        BOOL                                                 ~1      ~3
          8    > > JMPZ                                                         ~1, ->9
    7     9    > > RETURN                                                       null

End of function str_contains_eval

Function preg_match_eval:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 3
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
filename:       /in/3AXAY
function name:  preg_match_eval
number of ops:  4
compiled vars:  !0 = $show
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV_INIT                                            !0      ''
    9     1        FRAMELESS_ICALL_2                preg_match          ~1      '%2Furl%7Cdirectory%7Chome%2F', !0
          2      > JMPZ                                                         ~1, ->3
   10     3    > > RETURN                                                       null

End of function preg_match_eval

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.14 ms | 1763 KiB | 23 Q