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 ) );
Output for git.master
Ran str_replace() in 0.0493 microseconds average Ran substr() in 0.0269 microseconds average
Output for git.master_jit
Ran str_replace() in 0.0543 microseconds average Ran substr() in 0.0235 microseconds average
Output for rfc.property-hooks
Ran str_replace() in 0.0544 microseconds average Ran substr() in 0.0238 microseconds average

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.71 ms | 407 KiB | 5 Q