3v4l.org

run code in 300+ PHP versions simultaneously
<?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 ) );

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.20.0100.03317.84
8.4.10.0100.04523.87
8.3.150.0090.03216.73
8.3.140.0100.04516.68
8.3.130.0030.02018.48
8.3.120.0160.02618.95
8.3.110.0100.01320.94
8.3.100.0000.02424.06
8.3.90.0110.03526.77
8.3.80.0100.02018.43
8.3.70.0070.05116.50
8.3.60.0130.03018.68
8.3.50.0130.04416.54
8.3.40.0160.03920.29
8.3.30.0130.03021.03
8.3.20.0070.01624.18
8.3.10.0060.01624.66
8.3.00.0000.02326.16
8.2.270.0070.01617.29
8.2.260.0030.02017.26
8.2.250.0030.04016.87
8.2.240.0030.03417.41
8.2.230.0030.02022.58
8.2.220.0000.02537.54
8.2.210.0060.01626.77
8.2.200.0100.02016.75
8.2.190.0070.04416.63
8.2.180.0170.03616.63
8.2.170.0030.04119.00
8.2.160.0070.04922.96
8.2.150.0000.02325.66
8.2.140.0070.01724.66
8.2.130.0000.02326.16
8.2.120.0100.01319.77
8.2.110.0100.02619.29
8.2.100.0120.02217.97
8.2.90.0000.02717.88
8.2.80.0030.03218.92
8.2.70.0030.02517.75
8.2.60.0120.02717.61
8.2.50.0160.02417.50
8.2.40.0080.02817.37
8.2.30.0060.03217.63
8.2.20.0110.02717.63
8.2.10.0040.03317.35
8.2.00.0110.02517.50
8.1.310.0060.01617.05
8.1.300.0090.02518.55
8.1.290.0000.02818.88
8.1.280.0070.03425.92
8.1.270.0100.01324.66
8.1.260.0000.02326.35
8.1.250.0100.01328.09
8.1.240.0000.03623.92
8.1.230.0100.01922.62
8.1.220.0070.02017.74
8.1.210.0070.02018.77
8.1.200.0030.02417.38
8.1.190.0080.02817.13
8.1.180.0070.03217.13
8.1.170.0120.02717.11
8.1.160.0160.01917.11
8.1.150.0150.02117.25
8.1.140.0130.02317.25
8.1.130.0180.02117.25
8.1.120.0070.02917.25
8.1.110.0140.02117.00
8.1.100.0130.02317.25
8.1.90.0100.02617.50
8.1.80.0040.03317.38
8.1.70.0080.02817.13
8.1.60.0110.02617.25
8.1.50.0190.01717.50
8.1.40.0070.03017.23
8.1.30.0110.03017.35
8.1.20.0130.02517.13
8.1.10.0120.02817.38
8.1.00.0140.02617.63
8.0.300.0030.02618.77
8.0.290.0030.02816.63
8.0.280.0100.02916.52
8.0.270.0140.02716.73
8.0.260.0120.02716.63
8.0.250.0070.03216.52
8.0.240.0160.02216.61
8.0.230.0100.02816.52
8.0.220.0080.03116.75
8.0.210.0080.03116.75
8.0.200.0140.02516.63
8.0.190.0150.02616.61
8.0.180.0170.02316.52
8.0.170.0110.02616.62
8.0.160.0180.02116.63
8.0.150.0180.02116.75
8.0.140.0100.02816.63
8.0.130.0110.02816.52
8.0.120.0140.02216.59
8.0.110.0130.02516.72
8.0.100.0130.02616.61
8.0.90.0070.03016.74
8.0.80.0120.02716.73
8.0.70.0120.02616.63
8.0.60.0040.03116.92
8.0.50.0040.03416.52
8.0.30.0150.02416.52
8.0.20.0180.02416.52
8.0.10.0150.02416.61

preferences:
27.91 ms | 402 KiB | 5 Q