-
-
Save peterwilsoncc/580c8bea21f1cddfbd8ff151d8718024 to your computer and use it in GitHub Desktop.
Timing tests for https://core.trac.wordpress.org/ticket/56849
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PWCC\Nope\PreOptionTesting; | |
const RUNS = 10000; | |
// return; | |
add_action( 'init', function(){ | |
$run_time = 0; | |
get_option( 'siteurl' ); | |
for( $i = RUNS; $i > 0; $i-- ) { | |
$time_start = microtime( true ); | |
get_option( 'siteurl' ); | |
$run_time += microtime( true ) - $time_start; | |
} | |
echo '<pre>'; | |
echo 'option_siteurl: ' . ( $run_time / RUNS ) . ' seconds' . PHP_EOL; | |
echo '</pre>'; | |
}, 10 ); | |
add_action( 'init', function(){ | |
remove_filter( 'option_home', '_config_wp_home' ); | |
remove_filter( 'option_siteurl', '_config_wp_siteurl' ); | |
add_filter( 'pre_option_home', '_config_wp_home' ); | |
add_filter( 'pre_option_siteurl', '_config_wp_siteurl' ); | |
$run_time = 0; | |
get_option( 'siteurl' ); | |
for( $i = RUNS; $i > 0; $i-- ) { | |
$time_start = microtime( true ); | |
get_option( 'siteurl' ); | |
$run_time += microtime( true ) - $time_start; | |
} | |
echo '<pre>'; | |
echo 'pre_option_siteurl: ' . ( $run_time / RUNS ) . ' seconds' . PHP_EOL; | |
echo '</pre>'; | |
}, 20 ); | |
add_action( 'init', function(){ | |
exit; | |
}, 30 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment