3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_contains_eval( $show = '' ) { $url = true; if ( ! str_contains( $show, 'url' ) && ! str_contains( $show, 'directory' ) && ! str_contains( $show, 'home' ) ) { $url = false; } if ( $url ) {} } 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/dqBgA
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
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 1000
   21     1        INIT_FCALL                                               'hrtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   22     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->11
   23     7    >   INIT_FCALL                                               'str_contains_eval'
          8        SEND_VAL                                                 'blogname'
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !3, $10
   22    11    >   POST_INC                                         ~12     !2
         12        IS_SMALLER                                               ~12, !0
         13      > JMPNZ                                                    ~13, ->7
   24    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'
   26    21        INIT_FCALL                                               'hrtime'
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !1, $17
   27    25        ASSIGN                                                   !2, 0
         26      > JMP                                                      ->31
   28    27    >   INIT_FCALL                                               'preg_match_eval'
         28        SEND_VAL                                                 'blogname'
         29        DO_FCALL                                      0  $20     
         30        ASSIGN                                                   !3, $20
   27    31    >   POST_INC                                         ~22     !2
         32        IS_SMALLER                                               ~22, !0
         33      > JMPNZ                                                    ~23, ->27
   29    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'
   31    41        ECHO                                                     '%0A%3D%3D%3D+Warmed+up+%3D%3D%3D%0A%0A'
   33    42        ASSIGN                                                   !0, 100000
   35    43        INIT_FCALL                                               'hrtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $28     
         46        ASSIGN                                                   !1, $28
   36    47        ASSIGN                                                   !2, 0
         48      > JMP                                                      ->53
   37    49    >   INIT_FCALL                                               'str_contains_eval'
         50        SEND_VAL                                                 'blogname'
         51        DO_FCALL                                      0  $31     
         52        ASSIGN                                                   !3, $31
   36    53    >   POST_INC                                         ~33     !2
         54        IS_SMALLER                                               ~33, !0
         55      > JMPNZ                                                    ~34, ->49
   38    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'
   40    65        INIT_FCALL                                               'hrtime'
         66        SEND_VAL                                                 <true>
         67        DO_ICALL                                         $39     
         68        ASSIGN                                                   !1, $39
   41    69        ASSIGN                                                   !2, 0
         70      > JMP                                                      ->75
   42    71    >   INIT_FCALL                                               'preg_match_eval'
         72        SEND_VAL                                                 'blogname'
         73        DO_FCALL                                      0  $42     
         74        ASSIGN                                                   !3, $42
   41    75    >   POST_INC                                         ~44     !2
         76        IS_SMALLER                                               ~44, !0
         77      > JMPNZ                                                    ~45, ->71
   43    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'
   45    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 = 46) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 23
Branch analysis from position: 21
Branch analysis from position: 14
filename:       /in/dqBgA
function name:  str_contains_eval
number of ops:  25
compiled vars:  !0 = $show, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      ''
    4     1        ASSIGN                                                   !1, <true>
    6     2        INIT_FCALL                                               'str_contains'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'url'
          5        DO_ICALL                                         $3      
          6        BOOL_NOT                                         ~4      $3
          7      > JMPZ_EX                                          ~4      ~4, ->14
    7     8    >   INIT_FCALL                                               'str_contains'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'directory'
         11        DO_ICALL                                         $5      
         12        BOOL_NOT                                         ~6      $5
         13        BOOL                                             ~4      ~6
         14    > > JMPZ_EX                                          ~4      ~4, ->21
    8    15    >   INIT_FCALL                                               'str_contains'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 'home'
         18        DO_ICALL                                         $7      
         19        BOOL_NOT                                         ~8      $7
         20        BOOL                                             ~4      ~8
         21    > > JMPZ                                                     ~4, ->23
   10    22    >   ASSIGN                                                   !1, <false>
   13    23    > > JMPZ                                                     !1, ->24
   14    24    > > 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 = 6, Position 2 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/dqBgA
function name:  preg_match_eval
number of ops:  7
compiled vars:  !0 = $show
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                        !0      ''
   16     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2Furl%7Cdirectory%7Chome%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->6
   17     6    > > RETURN                                                   null

End of function preg_match_eval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.3 ms | 971 KiB | 21 Q