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_text_field( $a ) { return $a; } function determine_locale() { /** * 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 ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) { return $determined_locale; } $determined_locale = get_locale(); if ( is_admin() ) { $determined_locale = get_user_locale(); } if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) { $determined_locale = get_user_locale(); } $wp_lang = ''; if ( ! empty( $_GET['wp_lang'] ) ) { $wp_lang = sanitize_text_field( $_GET['wp_lang'] ); } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { $wp_lang = sanitize_text_field( $_COOKIE['wp_lang'] ); } if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { $determined_locale = $wp_lang; } /** * 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(); function determine_locale_new() { /** * 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_text_field( $_GET['wp_lang'] ) ?: $determined_locale; } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { $determined_locale = sanitize_text_field( $_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 ); } $its = 1e5; $t = hrtime(true); for ( $i = 0; $i++ < $its; ) determine_locale(); echo 'old: ', $old = ( hrtime(true)-$t ) / 1e9, "s\n"; $t = hrtime(true); for ( $i = 0; $i++ < $its; ) determine_locale_new(); echo 'new: ', $new = ( hrtime(true)-$t ) / 1e9, "s\n\n"; printf( 'New 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.60.0100.05618.31
8.3.50.0100.05716.84
8.3.40.0030.04923.79
8.3.30.0160.03618.98
8.3.20.0030.02424.18
8.3.10.0100.04824.66
8.3.00.0100.02526.16
8.2.180.0100.05116.35
8.2.170.0160.05218.92
8.2.160.0100.04222.96
8.2.150.0060.03525.66
8.2.140.0000.02824.66
8.2.130.0030.02426.16
8.2.120.0000.03417.93
8.2.110.0060.03920.46
8.2.100.0110.02917.91
8.2.90.0070.03017.97
8.2.80.0090.02518.03
8.2.70.0060.02917.63
8.2.60.0150.03817.29
8.2.50.0080.04817.50
8.2.40.0150.03517.38
8.2.30.0100.04017.50
8.2.20.0190.03217.75
8.2.10.0160.03317.50
8.2.00.0060.04017.25
8.1.280.0070.04725.92
8.1.270.0000.02924.66
8.1.260.0070.02126.35
8.1.250.0070.02128.09
8.1.240.0000.04622.30
8.1.230.0030.03122.09
8.1.220.0000.03417.78
8.1.210.0030.03019.04
8.1.200.0070.02817.00
8.1.190.0160.03117.00
8.1.180.0220.02516.97
8.1.170.0130.03217.25
8.1.160.0080.03417.35
8.1.150.0130.02917.13
8.1.140.0100.03117.00
8.1.130.0110.03217.38
8.1.120.0120.03217.38
8.1.110.0140.02917.25
8.1.100.0070.03517.38
8.1.90.0100.03217.23
8.1.80.0180.02917.13
8.1.70.0140.02917.50
8.1.60.0180.02717.38
8.1.50.0140.03117.38
8.1.40.0110.03317.35
8.1.30.0170.02817.25
8.1.20.0100.03517.63
8.1.10.0120.03717.38
8.1.00.0200.02619.04
8.0.300.0060.02620.07
8.0.290.0030.03316.88
8.0.280.0100.03416.72
8.0.270.0100.03616.52
8.0.260.0110.03516.52
8.0.250.0150.03016.75
8.0.240.0160.02916.52
8.0.230.0130.03216.88
8.0.220.0090.03616.75
8.0.210.0150.03016.75
8.0.200.0080.03816.75
8.0.190.0100.03516.71
8.0.180.0170.02816.63
8.0.170.0110.03316.75
8.0.160.0110.03716.74
8.0.150.0090.03516.62
8.0.140.0160.02716.63
8.0.130.0120.03116.61
8.0.120.0070.03716.61
8.0.110.0070.03716.72
8.0.100.0110.03416.71
8.0.90.0120.03116.60
8.0.80.0240.02716.52
8.0.70.0110.03316.75
8.0.60.0100.03416.62
8.0.50.0040.04116.71
8.0.30.0100.03416.71
8.0.20.0110.03316.84
8.0.10.0160.02816.87

preferences:
45.58 ms | 401 KiB | 5 Q