@ 2023-06-01T12:43:22Z <?php
// Most likely front-end scenario.
function is_admin() {
return true;
}
function wp_is_json_request() {
return false;
}
function get_locale() {
return 'en_US';
}
function get_user_locale() {
return 'en_US';
}
function apply_filters( $a, $b ) {
return $b;
}
function sanitize_locale_name( $a ) {
return $a;
}
function determine_locale_actual() {
/**
* Filters the locale for the current request prior to the default determination process.
*
* Using this filter allows to override the default logic, effectively short-circuiting the function.
*
* @since 5.0.0
*
* @param string|null $locale The locale to return and short-circuit. Default null.
*/
$determined_locale = apply_filters( 'pre_determine_locale', null );
if ( $determined_locale && is_string( $determined_locale ) ) {
return $determined_locale;
}
if (
isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] &&
( ! empty( $_GET['wp_lang'] ) || ! empty( $_COOKIE['wp_lang'] ) )
) {
if ( ! empty( $_GET['wp_lang'] ) ) {
$determined_locale = sanitize_locale_name( $_GET['wp_lang'] );
} else {
$determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] );
}
} else if (
( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) || is_admin()
) {
$determined_locale = get_user_locale();
} else {
$determined_locale = get_locale();
}
/**
* Filters the locale for the current request.
*
* @since 5.0.0
*
* @param string $locale The locale.
*/
return apply_filters( 'determine_locale', $determined_locale );
}
function determine_locale_proposed() {
/**
* Filters the locale for the current request prior to the default determination process.
*
* Using this filter allows to override the default logic, effectively short-circuiting the function.
*
* @since 5.0.0
*
* @param string|null $locale The locale to return and short-circuit. Default null.
*/
$determined_locale = apply_filters( 'pre_determine_locale', null );
if ( $determined_locale && is_string( $determined_locale ) ) {
return $determined_locale;
}
if (
is_admin()
|| ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() )
) {
$determined_locale = get_user_locale();
} else {
$determined_locale = get_locale();
}
if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) {
if ( ! empty( $_GET['wp_lang'] ) ) {
$determined_locale = sanitize_locale_name( $_GET['wp_lang'] ) ?: $determined_locale;
} elseif ( ! empty( $_COOKIE['wp_lang'] ) ) {
$determined_locale = sanitize_locale_name( $_COOKIE['wp_lang'] ) ?: $determined_locale;
}
}
/**
* Filters the locale for the current request.
*
* @since 5.0.0
*
* @param string $locale The locale.
*/
return apply_filters( 'determine_locale', $determined_locale );
}
determine_locale_actual();
determine_locale_proposed();
$its = 1e5;
$t = hrtime(true);
for ( $i = 0; $i++ < $its; )
determine_locale_actual();
echo 'current: ', $old = ( hrtime(true)-$t ) / 1e9, "s\n";
$t = hrtime(true);
for ( $i = 0; $i++ < $its; )
determine_locale_proposed();
echo 'proposed: ', $new = ( hrtime(true)-$t ) / 1e9, "s\n\n";
printf( 'Proposed is %sx faster', number_format( $old / $new, 2 ) );
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.2 0.010 0.033 17.84 8.4.1 0.010 0.045 23.87 8.3.15 0.009 0.032 16.73 8.3.14 0.010 0.045 16.68 8.3.13 0.003 0.020 18.48 8.3.12 0.016 0.026 18.95 8.3.11 0.010 0.013 20.94 8.3.10 0.000 0.024 24.06 8.3.9 0.011 0.035 26.77 8.3.8 0.010 0.020 18.43 8.3.7 0.007 0.051 16.50 8.3.6 0.013 0.030 18.68 8.3.5 0.013 0.044 16.54 8.3.4 0.016 0.039 20.29 8.3.3 0.013 0.030 21.03 8.3.2 0.007 0.016 24.18 8.3.1 0.006 0.016 24.66 8.3.0 0.000 0.023 26.16 8.2.27 0.007 0.016 17.29 8.2.26 0.003 0.020 17.26 8.2.25 0.003 0.040 16.87 8.2.24 0.003 0.034 17.41 8.2.23 0.003 0.020 22.58 8.2.22 0.000 0.025 37.54 8.2.21 0.006 0.016 26.77 8.2.20 0.010 0.020 16.75 8.2.19 0.007 0.044 16.63 8.2.18 0.017 0.036 16.63 8.2.17 0.003 0.041 19.00 8.2.16 0.007 0.049 22.96 8.2.15 0.000 0.023 25.66 8.2.14 0.007 0.017 24.66 8.2.13 0.000 0.023 26.16 8.2.12 0.010 0.013 19.77 8.2.11 0.010 0.026 19.29 8.2.10 0.012 0.022 17.97 8.2.9 0.000 0.027 17.88 8.2.8 0.003 0.032 18.92 8.2.7 0.003 0.025 17.75 8.2.6 0.012 0.027 17.61 8.2.5 0.016 0.024 17.50 8.2.4 0.008 0.028 17.37 8.2.3 0.006 0.032 17.63 8.2.2 0.011 0.027 17.63 8.2.1 0.004 0.033 17.35 8.2.0 0.011 0.025 17.50 8.1.31 0.006 0.016 17.05 8.1.30 0.009 0.025 18.55 8.1.29 0.000 0.028 18.88 8.1.28 0.007 0.034 25.92 8.1.27 0.010 0.013 24.66 8.1.26 0.000 0.023 26.35 8.1.25 0.010 0.013 28.09 8.1.24 0.000 0.036 23.92 8.1.23 0.010 0.019 22.62 8.1.22 0.007 0.020 17.74 8.1.21 0.007 0.020 18.77 8.1.20 0.003 0.024 17.38 8.1.19 0.008 0.028 17.13 8.1.18 0.007 0.032 17.13 8.1.17 0.012 0.027 17.11 8.1.16 0.016 0.019 17.11 8.1.15 0.015 0.021 17.25 8.1.14 0.013 0.023 17.25 8.1.13 0.018 0.021 17.25 8.1.12 0.007 0.029 17.25 8.1.11 0.014 0.021 17.00 8.1.10 0.013 0.023 17.25 8.1.9 0.010 0.026 17.50 8.1.8 0.004 0.033 17.38 8.1.7 0.008 0.028 17.13 8.1.6 0.011 0.026 17.25 8.1.5 0.019 0.017 17.50 8.1.4 0.007 0.030 17.23 8.1.3 0.011 0.030 17.35 8.1.2 0.013 0.025 17.13 8.1.1 0.012 0.028 17.38 8.1.0 0.014 0.026 17.63 8.0.30 0.003 0.026 18.77 8.0.29 0.003 0.028 16.63 8.0.28 0.010 0.029 16.52 8.0.27 0.014 0.027 16.73 8.0.26 0.012 0.027 16.63 8.0.25 0.007 0.032 16.52 8.0.24 0.016 0.022 16.61 8.0.23 0.010 0.028 16.52 8.0.22 0.008 0.031 16.75 8.0.21 0.008 0.031 16.75 8.0.20 0.014 0.025 16.63 8.0.19 0.015 0.026 16.61 8.0.18 0.017 0.023 16.52 8.0.17 0.011 0.026 16.62 8.0.16 0.018 0.021 16.63 8.0.15 0.018 0.021 16.75 8.0.14 0.010 0.028 16.63 8.0.13 0.011 0.028 16.52 8.0.12 0.014 0.022 16.59 8.0.11 0.013 0.025 16.72 8.0.10 0.013 0.026 16.61 8.0.9 0.007 0.030 16.74 8.0.8 0.012 0.027 16.73 8.0.7 0.012 0.026 16.63 8.0.6 0.004 0.031 16.92 8.0.5 0.004 0.034 16.52 8.0.3 0.015 0.024 16.52 8.0.2 0.018 0.024 16.52 8.0.1 0.015 0.024 16.61
preferences:dark mode live preview
27.91 ms | 402 KiB | 5 Q