3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Most likely front-end scenario. function is_admin() { return false; } 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.3.110.0040.03220.94
8.3.100.0060.01924.06
8.3.90.0070.02426.77
8.3.80.0060.02518.55
8.3.70.0160.02918.27
8.3.60.0170.03016.75
8.3.50.0070.03816.47
8.3.40.0190.03820.47
8.3.30.0100.03620.75
8.3.20.0060.01824.18
8.3.10.0060.01824.66
8.3.00.0030.02226.16
8.2.230.0070.02222.58
8.2.220.0070.03037.54
8.2.210.0000.02526.77
8.2.200.0030.04016.63
8.2.190.0100.04416.79
8.2.180.0140.04416.75
8.2.170.0160.04418.91
8.2.160.0130.03522.96
8.2.150.0070.02325.66
8.2.140.0060.01924.66
8.2.130.0000.02526.16
8.2.120.0040.02119.48
8.2.110.0030.03722.24
8.2.100.0000.03417.97
8.2.90.0030.02617.63
8.2.80.0040.02617.97
8.2.70.0030.02717.63
8.2.60.0080.03317.50
8.2.50.0110.02917.38
8.2.40.0100.02917.75
8.2.30.0060.03317.63
8.2.20.0100.02917.50
8.2.10.0070.03217.38
8.2.00.0120.02817.38
8.1.290.0030.02830.84
8.1.280.0130.03225.92
8.1.270.0030.02124.66
8.1.260.0000.02426.35
8.1.250.0040.02228.09
8.1.240.0060.03223.92
8.1.230.0100.02619.18
8.1.220.0060.02517.78
8.1.210.0070.02318.77
8.1.200.0090.01917.35
8.1.190.0110.02816.84
8.1.180.0100.03117.13
8.1.170.0140.03217.00
8.1.160.0140.02417.23
8.1.150.0090.02817.10
8.1.140.0060.02419.01
8.1.130.0170.02217.25
8.1.120.0100.02717.25
8.1.110.0070.03417.25
8.1.100.0080.03217.10
8.1.90.0030.03417.38
8.1.80.0190.02217.50
8.1.70.0170.02317.25
8.1.60.0120.02817.35
8.1.50.0180.02117.38
8.1.40.0150.02417.60
8.1.30.0220.01917.35
8.1.20.0190.02217.59
8.1.10.0040.03617.50
8.1.00.0130.02717.38
8.0.300.0060.02320.16
8.0.290.0030.02716.75
8.0.280.0150.02516.75
8.0.270.0170.02416.63
8.0.260.0100.03016.52
8.0.250.0200.02116.75
8.0.240.0140.02516.63
8.0.230.0140.02416.73
8.0.220.0120.02916.72
8.0.210.0120.02816.75
8.0.200.0100.03016.75
8.0.190.0100.03116.75
8.0.180.0100.03516.75
8.0.170.0100.03116.88
8.0.160.0110.03116.75
8.0.150.0160.02316.59
8.0.140.0140.02516.60
8.0.130.0190.02216.72
8.0.120.0130.02516.52
8.0.110.0150.02616.52
8.0.100.0100.03216.52
8.0.90.0080.03116.71
8.0.80.0120.02816.52
8.0.70.0140.02516.60
8.0.60.0070.03017.18
8.0.50.0100.03116.52
8.0.30.0150.02516.63
8.0.20.0220.02016.75
8.0.10.0160.02816.52

preferences:
28.03 ms | 403 KiB | 5 Q