3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Run a million cycles for the profile averages. $cycles = 1000000; // Setup. define( 'WP_PLUGIN_DIR', 'absolute/path/to/the/plugins/dir' ); $plugin = 'plugin/plugin.php'; $plugins_dir = trailingslashit( WP_PLUGIN_DIR ); $plugins_dir_strlen = strlen( $plugins_dir ); // Polyfills. function trailingslashit( $value ) { return untrailingslashit( $value ) . '/'; } function untrailingslashit( $value ) { return rtrim( $value, '/\\' ); } // Test str_replace(). $start_time = microtime( true ); for ( $i = 1; $i <= $cycles; $i++ ) { $plugin_file = str_replace( $plugins_dir, '', $plugin ); } $end_time = microtime( true ); $total_time = ( $end_time - $start_time ) * 1000000.0; printf( "Ran str_replace() in %s microseconds average\n", number_format( $total_time / $cycles, 4 ) ); // Test substr(). $start_time = microtime( true ); for ( $i = 1; $i <= $cycles; $i++ ) { $plugin_file = substr( $plugin, $plugins_dir_strlen ); } $end_time = microtime( true ); $total_time = ( $end_time - $start_time ) * 1000000.0; printf( "Ran substr() in %s microseconds average\n", number_format( $total_time / $cycles, 4 ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 19
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 47
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 47
Branch analysis from position: 52
Branch analysis from position: 47
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 19
Branch analysis from position: 25
Branch analysis from position: 19
filename:       /in/TbQ9U
function name:  (null)
number of ops:  69
compiled vars:  !0 = $cycles, !1 = $plugin, !2 = $plugins_dir, !3 = $plugins_dir_strlen, !4 = $start_time, !5 = $i, !6 = $plugin_file, !7 = $end_time, !8 = $total_time
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, 1000000
    7     1        INIT_FCALL                                                   'define'
          2        SEND_VAL                                                     'WP_PLUGIN_DIR'
          3        SEND_VAL                                                     'absolute%2Fpath%2Fto%2Fthe%2Fplugins%2Fdir'
          4        DO_ICALL                                                     
    8     5        ASSIGN                                                       !1, 'plugin%2Fplugin.php'
    9     6        INIT_FCALL_BY_NAME                                           'trailingslashit'
          7        FETCH_CONSTANT                                       ~12     'WP_PLUGIN_DIR'
          8        SEND_VAL_EX                                                  ~12
          9        DO_FCALL                                          0  $13     
         10        ASSIGN                                                       !2, $13
   10    11        STRLEN                                               ~15     !2
         12        ASSIGN                                                       !3, ~15
   22    13        INIT_FCALL                                                   'microtime'
         14        SEND_VAL                                                     <true>
         15        DO_ICALL                                             $17     
         16        ASSIGN                                                       !4, $17
   23    17        ASSIGN                                                       !5, 1
         18      > JMP                                                          ->23
   24    19    >   FRAMELESS_ICALL_3                str_replace         ~20     !2, ''
         20        OP_DATA                                                      !1
         21        ASSIGN                                                       !6, ~20
   23    22        PRE_INC                                                      !5
         23    >   IS_SMALLER_OR_EQUAL                                          !5, !0
         24      > JMPNZ                                                        ~23, ->19
   26    25    >   INIT_FCALL                                                   'microtime'
         26        SEND_VAL                                                     <true>
         27        DO_ICALL                                             $24     
         28        ASSIGN                                                       !7, $24
   27    29        SUB                                                  ~26     !7, !4
         30        MUL                                                  ~27     ~26, 1.0e+6
         31        ASSIGN                                                       !8, ~27
   28    32        INIT_FCALL                                                   'printf'
         33        SEND_VAL                                                     'Ran+str_replace%28%29+in+%25s+microseconds+average%0A'
   29    34        INIT_FCALL                                                   'number_format'
         35        DIV                                                  ~29     !8, !0
         36        SEND_VAL                                                     ~29
         37        SEND_VAL                                                     4
         38        DO_ICALL                                             $30     
         39        SEND_VAR                                                     $30
   28    40        DO_ICALL                                                     
   33    41        INIT_FCALL                                                   'microtime'
         42        SEND_VAL                                                     <true>
         43        DO_ICALL                                             $32     
         44        ASSIGN                                                       !4, $32
   34    45        ASSIGN                                                       !5, 1
         46      > JMP                                                          ->50
   35    47    >   FRAMELESS_ICALL_2                substr              ~35     !1, !3
         48        ASSIGN                                                       !6, ~35
   34    49        PRE_INC                                                      !5
         50    >   IS_SMALLER_OR_EQUAL                                          !5, !0
         51      > JMPNZ                                                        ~38, ->47
   37    52    >   INIT_FCALL                                                   'microtime'
         53        SEND_VAL                                                     <true>
         54        DO_ICALL                                             $39     
         55        ASSIGN                                                       !7, $39
   38    56        SUB                                                  ~41     !7, !4
         57        MUL                                                  ~42     ~41, 1.0e+6
         58        ASSIGN                                                       !8, ~42
   39    59        INIT_FCALL                                                   'printf'
         60        SEND_VAL                                                     'Ran+substr%28%29+in+%25s+microseconds+average%0A'
   40    61        INIT_FCALL                                                   'number_format'
         62        DIV                                                  ~44     !8, !0
         63        SEND_VAL                                                     ~44
         64        SEND_VAL                                                     4
         65        DO_ICALL                                             $45     
         66        SEND_VAR                                                     $45
   39    67        DO_ICALL                                                     
   41    68      > RETURN                                                       1

Function trailingslashit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TbQ9U
function name:  trailingslashit
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        INIT_FCALL_BY_NAME                                           'untrailingslashit'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4        CONCAT                                               ~2      $1, '%2F'
          5      > RETURN                                                       ~2
   15     6*     > RETURN                                                       null

End of function trailingslashit

Function untrailingslashit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TbQ9U
function name:  untrailingslashit
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   17     1        INIT_FCALL                                                   'rtrim'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     '%2F%5C'
          4        DO_ICALL                                             $1      
          5      > RETURN                                                       $1
   18     6*     > RETURN                                                       null

End of function untrailingslashit

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.82 ms | 3029 KiB | 18 Q