3v4l.org

run code in 300+ 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 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 19
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 50
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 50
Branch analysis from position: 58
Branch analysis from position: 50
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 19
Branch analysis from position: 28
Branch analysis from position: 19
filename:       /in/TbQ9U
function name:  (null)
number of ops:  75
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                                                      ->26
   24    19    >   INIT_FCALL                                               'str_replace'
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 ''
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $20     
         24        ASSIGN                                                   !6, $20
   23    25        PRE_INC                                                  !5
         26    >   IS_SMALLER_OR_EQUAL                                      !5, !0
         27      > JMPNZ                                                    ~23, ->19
   26    28    >   INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $24     
         31        ASSIGN                                                   !7, $24
   27    32        SUB                                              ~26     !7, !4
         33        MUL                                              ~27     ~26, 1.0e+6
         34        ASSIGN                                                   !8, ~27
   28    35        INIT_FCALL                                               'printf'
         36        SEND_VAL                                                 'Ran+str_replace%28%29+in+%25s+microseconds+average%0A'
   29    37        INIT_FCALL                                               'number_format'
         38        DIV                                              ~29     !8, !0
         39        SEND_VAL                                                 ~29
         40        SEND_VAL                                                 4
         41        DO_ICALL                                         $30     
         42        SEND_VAR                                                 $30
   28    43        DO_ICALL                                                 
   33    44        INIT_FCALL                                               'microtime'
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $32     
         47        ASSIGN                                                   !4, $32
   34    48        ASSIGN                                                   !5, 1
         49      > JMP                                                      ->56
   35    50    >   INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !1
         52        SEND_VAR                                                 !3
         53        DO_ICALL                                         $35     
         54        ASSIGN                                                   !6, $35
   34    55        PRE_INC                                                  !5
         56    >   IS_SMALLER_OR_EQUAL                                      !5, !0
         57      > JMPNZ                                                    ~38, ->50
   37    58    >   INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $39     
         61        ASSIGN                                                   !7, $39
   38    62        SUB                                              ~41     !7, !4
         63        MUL                                              ~42     ~41, 1.0e+6
         64        ASSIGN                                                   !8, ~42
   39    65        INIT_FCALL                                               'printf'
         66        SEND_VAL                                                 'Ran+substr%28%29+in+%25s+microseconds+average%0A'
   40    67        INIT_FCALL                                               'number_format'
         68        DIV                                              ~44     !8, !0
         69        SEND_VAL                                                 ~44
         70        SEND_VAL                                                 4
         71        DO_ICALL                                         $45     
         72        SEND_VAR                                                 $45
   39    73        DO_ICALL                                                 
   41    74      > 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.0.0


preferences:
163.82 ms | 1475 KiB | 20 Q