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 ) );
Output for 8.3.7
current: 0.015089751s proposed: 0.015254269s Proposed is 0.99x faster
Output for 8.3.6
current: 0.015674942s proposed: 0.016010507s Proposed is 0.98x faster
Output for 8.3.5
current: 0.01526086s proposed: 0.014642239s Proposed is 1.04x faster
Output for 8.3.4
current: 0.022505155s proposed: 0.015531108s Proposed is 1.45x faster
Output for 8.3.3
current: 0.016029206s proposed: 0.015484056s Proposed is 1.04x faster
Output for 8.3.2
current: 0.008427347s proposed: 0.008321238s Proposed is 1.01x faster
Output for 8.3.1
current: 0.008411091s proposed: 0.008366835s Proposed is 1.01x faster
Output for 8.3.0
current: 0.008660563s proposed: 0.008621204s Proposed is 1.00x faster
Output for 8.2.19
current: 0.019532656s proposed: 0.014693513s Proposed is 1.33x faster
Output for 8.2.18
current: 0.019988159s proposed: 0.018787219s Proposed is 1.06x faster
Output for 8.2.17
current: 0.021546254s proposed: 0.019214971s Proposed is 1.12x faster
Output for 8.2.16
current: 0.016380395s proposed: 0.01570019s Proposed is 1.04x faster
Output for 8.2.15
current: 0.008288035s proposed: 0.008049877s Proposed is 1.03x faster
Output for 8.2.14
current: 0.008599755s proposed: 0.008040172s Proposed is 1.07x faster
Output for 8.2.13
current: 0.008325884s proposed: 0.008367458s Proposed is 1.00x faster
Output for 8.2.12
current: 0.008521937s proposed: 0.008274415s Proposed is 1.03x faster
Output for 8.2.11
current: 0.015566353s proposed: 0.014788661s Proposed is 1.05x faster
Output for 8.2.10
current: 0.01151793s proposed: 0.011036997s Proposed is 1.04x faster
Output for 8.2.9
current: 0.01105371s proposed: 0.010675807s Proposed is 1.04x faster
Output for 8.2.8
current: 0.011217959s proposed: 0.010375372s Proposed is 1.08x faster
Output for 8.2.7
current: 0.011445562s proposed: 0.011025841s Proposed is 1.04x faster
Output for 8.2.6
current: 0.01159719s proposed: 0.011245799s Proposed is 1.03x faster
Output for 8.2.5
current: 0.010933059s proposed: 0.01045538s Proposed is 1.05x faster
Output for 8.2.4
current: 0.01105033s proposed: 0.010536912s Proposed is 1.05x faster
Output for 8.2.3
current: 0.011887829s proposed: 0.010871263s Proposed is 1.09x faster
Output for 8.2.2
current: 0.010904695s proposed: 0.010505794s Proposed is 1.04x faster
Output for 8.2.1
current: 0.011520475s proposed: 0.01097082s Proposed is 1.05x faster
Output for 8.2.0
current: 0.011561203s proposed: 0.011645652s Proposed is 0.99x faster
Output for 8.1.28
current: 0.015180258s proposed: 0.014615606s Proposed is 1.04x faster
Output for 8.1.27
current: 0.008403348s proposed: 0.008122214s Proposed is 1.03x faster
Output for 8.1.26
current: 0.008435272s proposed: 0.008128982s Proposed is 1.04x faster
Output for 8.1.25
current: 0.008288016s proposed: 0.00817828s Proposed is 1.01x faster
Output for 8.1.24
current: 0.015262329s proposed: 0.014756378s Proposed is 1.03x faster
Output for 8.1.23
current: 0.011978577s proposed: 0.008790888s Proposed is 1.36x faster
Output for 8.1.22
current: 0.011389506s proposed: 0.010879223s Proposed is 1.05x faster
Output for 8.1.21
current: 0.010830667s proposed: 0.010765475s Proposed is 1.01x faster
Output for 8.1.20
current: 0.010468761s proposed: 0.01006013s Proposed is 1.04x faster
Output for 8.1.19
current: 0.011488767s proposed: 0.010093166s Proposed is 1.14x faster
Output for 8.1.18
current: 0.012134753s proposed: 0.010843861s Proposed is 1.12x faster
Output for 8.1.17
current: 0.012154861s proposed: 0.01077474s Proposed is 1.13x faster
Output for 8.1.16
current: 0.010831288s proposed: 0.010351392s Proposed is 1.05x faster
Output for 8.1.15
current: 0.010664703s proposed: 0.00989808s Proposed is 1.08x faster
Output for 8.1.14
current: 0.010794617s proposed: 0.010179279s Proposed is 1.06x faster
Output for 8.1.13
current: 0.01072101s proposed: 0.010632383s Proposed is 1.01x faster
Output for 8.1.12
current: 0.01063599s proposed: 0.010240335s Proposed is 1.04x faster
Output for 8.1.11
current: 0.011114952s proposed: 0.010408842s Proposed is 1.07x faster
Output for 8.1.10
current: 0.010740757s proposed: 0.010414422s Proposed is 1.03x faster
Output for 8.1.9
current: 0.010673661s proposed: 0.010286811s Proposed is 1.04x faster
Output for 8.1.8
current: 0.011582032s proposed: 0.009937764s Proposed is 1.17x faster
Output for 8.1.7
current: 0.010799368s proposed: 0.0103179s Proposed is 1.05x faster
Output for 8.1.6
current: 0.010699209s proposed: 0.010509501s Proposed is 1.02x faster
Output for 8.1.5
current: 0.01063662s proposed: 0.010366041s Proposed is 1.03x faster
Output for 8.1.4
current: 0.010606965s proposed: 0.010145475s Proposed is 1.05x faster
Output for 8.1.3
current: 0.010568633s proposed: 0.010595943s Proposed is 1.00x faster
Output for 8.1.2
current: 0.011281956s proposed: 0.01116666s Proposed is 1.01x faster
Output for 8.1.1
current: 0.010883978s proposed: 0.010565526s Proposed is 1.03x faster
Output for 8.1.0
current: 0.011383328s proposed: 0.010706453s Proposed is 1.06x faster
Output for 8.0.30
current: 0.01098992s proposed: 0.010577814s Proposed is 1.04x faster
Output for 8.0.29
current: 0.011406768s proposed: 0.011640969s Proposed is 0.98x faster
Output for 8.0.28
current: 0.012454275s proposed: 0.011532277s Proposed is 1.08x faster
Output for 8.0.27
current: 0.012172704s proposed: 0.01196282s Proposed is 1.02x faster
Output for 8.0.26
current: 0.012535448s proposed: 0.011865577s Proposed is 1.06x faster
Output for 8.0.25
current: 0.012470667s proposed: 0.012001862s Proposed is 1.04x faster
Output for 8.0.24
current: 0.012144241s proposed: 0.011466193s Proposed is 1.06x faster
Output for 8.0.23
current: 0.011842882s proposed: 0.011258233s Proposed is 1.05x faster
Output for 8.0.22
current: 0.01274846s proposed: 0.011492924s Proposed is 1.11x faster
Output for 8.0.21
current: 0.011893318s proposed: 0.011863743s Proposed is 1.00x faster
Output for 8.0.20
current: 0.012482368s proposed: 0.011626496s Proposed is 1.07x faster
Output for 8.0.19
current: 0.012919412s proposed: 0.012290586s Proposed is 1.05x faster
Output for 8.0.18
current: 0.014502194s proposed: 0.012860852s Proposed is 1.13x faster
Output for 8.0.17
current: 0.012718563s proposed: 0.011492182s Proposed is 1.11x faster
Output for 8.0.16
current: 0.012875348s proposed: 0.011638658s Proposed is 1.11x faster
Output for 8.0.15
current: 0.012187593s proposed: 0.011186867s Proposed is 1.09x faster
Output for 8.0.14
current: 0.012219393s proposed: 0.011152061s Proposed is 1.10x faster
Output for 8.0.13
current: 0.011823888s proposed: 0.014157555s Proposed is 0.84x faster
Output for 8.0.12
current: 0.011696658s proposed: 0.010755835s Proposed is 1.09x faster
Output for 8.0.11
current: 0.012289265s proposed: 0.011452067s Proposed is 1.07x faster
Output for 8.0.10
current: 0.01161317s proposed: 0.011948674s Proposed is 0.97x faster
Output for 8.0.9
current: 0.011946989s proposed: 0.011298659s Proposed is 1.06x faster
Output for 8.0.8
current: 0.011732965s proposed: 0.011611789s Proposed is 1.01x faster
Output for 8.0.7
current: 0.011726514s proposed: 0.011135461s Proposed is 1.05x faster
Output for 8.0.6
current: 0.011665208s proposed: 0.011244326s Proposed is 1.04x faster
Output for 8.0.5
current: 0.011690516s proposed: 0.011285232s Proposed is 1.04x faster
Output for 8.0.3
current: 0.01118358s proposed: 0.011083542s Proposed is 1.01x faster
Output for 8.0.2
current: 0.012902249s proposed: 0.011884831s Proposed is 1.09x faster
Output for 8.0.1
current: 0.011722086s proposed: 0.011508573s Proposed is 1.02x faster

preferences:
62.99 ms | 401 KiB | 91 Q