3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Most likely admin 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_text_field( $a ) { return $a; } function determine_locale_notem() { /** * 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; } 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 ); } function determine_locale_plain() { /** * 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_notem(); echo 'notem: ', $notem = ( hrtime(true)-$t ) / 1e9, "s\n"; $t = hrtime(true); for ( $i = 0; $i++ < $its; ) determine_locale_plain(); echo 'plain: ', $plain = ( hrtime(true)-$t ) / 1e9, "s\n\n"; printf( 'Plain is %sx faster', number_format( $notem / $plain, 2 ) );
Output for 8.3.9
notem: 0.006883595s plain: 0.00650793s Plain is 1.06x faster
Output for 8.3.8
notem: 0.010099006s plain: 0.008794422s Plain is 1.15x faster
Output for 8.3.7
notem: 0.018712037s plain: 0.014503812s Plain is 1.29x faster
Output for 8.3.6
notem: 0.016302532s plain: 0.014070477s Plain is 1.16x faster
Output for 8.3.5
notem: 0.018920199s plain: 0.018012593s Plain is 1.05x faster
Output for 8.3.4
notem: 0.019228934s plain: 0.01773623s Plain is 1.08x faster
Output for 8.3.3
notem: 0.01351934s plain: 0.012297972s Plain is 1.10x faster
Output for 8.3.2
notem: 0.00698008s plain: 0.006736655s Plain is 1.04x faster
Output for 8.3.1
notem: 0.006660995s plain: 0.006534595s Plain is 1.02x faster
Output for 8.3.0
notem: 0.006835343s plain: 0.006837478s Plain is 1.00x faster
Output for 8.2.21
notem: 0.014382264s plain: 0.012204277s Plain is 1.18x faster
Output for 8.2.20
notem: 0.009527851s plain: 0.008385701s Plain is 1.14x faster
Output for 8.2.19
notem: 0.015277426s plain: 0.01254209s Plain is 1.22x faster
Output for 8.2.18
notem: 0.012142215s plain: 0.011599367s Plain is 1.05x faster
Output for 8.2.17
notem: 0.012361629s plain: 0.012199776s Plain is 1.01x faster
Output for 8.2.16
notem: 0.013203642s plain: 0.012521455s Plain is 1.05x faster
Output for 8.2.15
notem: 0.006812376s plain: 0.006634769s Plain is 1.03x faster
Output for 8.2.14
notem: 0.013938967s plain: 0.006430146s Plain is 2.17x faster
Output for 8.2.13
notem: 0.006870973s plain: 0.006582458s Plain is 1.04x faster
Output for 8.2.12
notem: 0.007024472s plain: 0.006502216s Plain is 1.08x faster
Output for 8.2.11
notem: 0.012043114s plain: 0.010763309s Plain is 1.12x faster
Output for 8.2.10
notem: 0.009400957s plain: 0.008282734s Plain is 1.14x faster
Output for 8.2.9
notem: 0.009490573s plain: 0.008224137s Plain is 1.15x faster
Output for 8.2.8
notem: 0.009818431s plain: 0.007911087s Plain is 1.24x faster
Output for 8.2.7
notem: 0.009486852s plain: 0.008193516s Plain is 1.16x faster
Output for 8.2.6
notem: 0.009338587s plain: 0.008130812s Plain is 1.15x faster
Output for 8.2.5
notem: 0.009445168s plain: 0.008008592s Plain is 1.18x faster
Output for 8.2.4
notem: 0.009938927s plain: 0.008472345s Plain is 1.17x faster
Output for 8.2.3
notem: 0.009187032s plain: 0.008321471s Plain is 1.10x faster
Output for 8.2.2
notem: 0.009318448s plain: 0.008190935s Plain is 1.14x faster
Output for 8.2.1
notem: 0.00928133s plain: 0.00833672s Plain is 1.11x faster
Output for 8.2.0
notem: 0.010927199s plain: 0.011328144s Plain is 0.96x faster
Output for 8.1.29
notem: 0.008986483s plain: 0.00851561s Plain is 1.06x faster
Output for 8.1.28
notem: 0.015228983s plain: 0.013610875s Plain is 1.12x faster
Output for 8.1.27
notem: 0.006779337s plain: 0.006752417s Plain is 1.00x faster
Output for 8.1.26
notem: 0.006890769s plain: 0.00653984s Plain is 1.05x faster
Output for 8.1.25
notem: 0.006934252s plain: 0.00660103s Plain is 1.05x faster
Output for 8.1.24
notem: 0.011341691s plain: 0.01105497s Plain is 1.03x faster
Output for 8.1.23
notem: 0.007670492s plain: 0.007306838s Plain is 1.05x faster
Output for 8.1.22
notem: 0.008760873s plain: 0.007732156s Plain is 1.13x faster
Output for 8.1.21
notem: 0.009072464s plain: 0.007676415s Plain is 1.18x faster
Output for 8.1.20
notem: 0.008990534s plain: 0.007844664s Plain is 1.15x faster
Output for 8.1.19
notem: 0.009319982s plain: 0.007803607s Plain is 1.19x faster
Output for 8.1.18
notem: 0.00884595s plain: 0.00771037s Plain is 1.15x faster
Output for 8.1.17
notem: 0.009244149s plain: 0.007995808s Plain is 1.16x faster
Output for 8.1.16
notem: 0.009184086s plain: 0.008210322s Plain is 1.12x faster
Output for 8.1.15
notem: 0.00832587s plain: 0.00752945s Plain is 1.11x faster
Output for 8.1.14
notem: 0.009167715s plain: 0.008154267s Plain is 1.12x faster
Output for 8.1.13
notem: 0.009088796s plain: 0.008136163s Plain is 1.12x faster
Output for 8.1.12
notem: 0.009483019s plain: 0.008269333s Plain is 1.15x faster
Output for 8.1.11
notem: 0.009094487s plain: 0.007728946s Plain is 1.18x faster
Output for 8.1.10
notem: 0.009233029s plain: 0.007723415s Plain is 1.20x faster
Output for 8.1.9
notem: 0.008856889s plain: 0.008132616s Plain is 1.09x faster
Output for 8.1.8
notem: 0.009068709s plain: 0.008171158s Plain is 1.11x faster
Output for 8.1.7
notem: 0.008885173s plain: 0.008042156s Plain is 1.10x faster
Output for 8.1.6
notem: 0.009006081s plain: 0.007650818s Plain is 1.18x faster
Output for 8.1.5
notem: 0.009054021s plain: 0.007729446s Plain is 1.17x faster
Output for 8.1.4
notem: 0.009107662s plain: 0.007571299s Plain is 1.20x faster
Output for 8.1.3
notem: 0.008997665s plain: 0.007854782s Plain is 1.15x faster
Output for 8.1.2
notem: 0.008892017s plain: 0.008089034s Plain is 1.10x faster
Output for 8.1.1
notem: 0.00939351s plain: 0.008263903s Plain is 1.14x faster
Output for 8.1.0
notem: 0.009054061s plain: 0.007983906s Plain is 1.13x faster
Output for 8.0.30
notem: 0.011418958s plain: 0.009110188s Plain is 1.25x faster
Output for 8.0.29
notem: 0.010395193s plain: 0.009532817s Plain is 1.09x faster
Output for 8.0.28
notem: 0.012475335s plain: 0.009649813s Plain is 1.29x faster
Output for 8.0.27
notem: 0.012120526s plain: 0.009736867s Plain is 1.24x faster
Output for 8.0.26
notem: 0.011941759s plain: 0.009932135s Plain is 1.20x faster
Output for 8.0.25
notem: 0.012172253s plain: 0.009374824s Plain is 1.30x faster
Output for 8.0.24
notem: 0.011977236s plain: 0.009204676s Plain is 1.30x faster
Output for 8.0.23
notem: 0.01058842s plain: 0.00937706s Plain is 1.13x faster
Output for 8.0.22
notem: 0.012112051s plain: 0.009811788s Plain is 1.23x faster
Output for 8.0.21
notem: 0.011847573s plain: 0.009616731s Plain is 1.23x faster
Output for 8.0.20
notem: 0.011855577s plain: 0.010154102s Plain is 1.17x faster
Output for 8.0.19
notem: 0.011796516s plain: 0.010156407s Plain is 1.16x faster
Output for 8.0.18
notem: 0.011180275s plain: 0.009542501s Plain is 1.17x faster
Output for 8.0.17
notem: 0.011658666s plain: 0.010748152s Plain is 1.08x faster
Output for 8.0.16
notem: 0.01120447s plain: 0.0097919s Plain is 1.14x faster
Output for 8.0.15
notem: 0.011636143s plain: 0.009363885s Plain is 1.24x faster
Output for 8.0.14
notem: 0.010665586s plain: 0.008701998s Plain is 1.23x faster
Output for 8.0.13
notem: 0.011260857s plain: 0.009296919s Plain is 1.21x faster
Output for 8.0.12
notem: 0.012699548s plain: 0.009331184s Plain is 1.36x faster
Output for 8.0.11
notem: 0.011324969s plain: 0.009281148s Plain is 1.22x faster
Output for 8.0.10
notem: 0.011711004s plain: 0.009050043s Plain is 1.29x faster
Output for 8.0.9
notem: 0.011289492s plain: 0.009112161s Plain is 1.24x faster
Output for 8.0.8
notem: 0.011683974s plain: 0.009642559s Plain is 1.21x faster
Output for 8.0.7
notem: 0.010945043s plain: 0.008985542s Plain is 1.22x faster
Output for 8.0.6
notem: 0.010271705s plain: 0.009296888s Plain is 1.10x faster
Output for 8.0.5
notem: 0.010422168s plain: 0.009587065s Plain is 1.09x faster
Output for 8.0.3
notem: 0.010499613s plain: 0.009448584s Plain is 1.11x faster
Output for 8.0.2
notem: 0.012559833s plain: 0.010054957s Plain is 1.25x faster
Output for 8.0.1
notem: 0.010602286s plain: 0.009566667s Plain is 1.11x faster

preferences:
123.56 ms | 403 KiB | 96 Q