3v4l.org

run code in 500+ 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 ) );
Output for 8.6.0
old: 0.039298905s new: 0.017483005s New is 2.25x faster
Output for 8.5.13
old: 0.037964812s new: 0.021912184s New is 1.73x faster
Output for 8.5.12
old: 0.03803059s new: 0.031312486s New is 1.21x faster
Output for 8.5.11
old: 0.040059938s new: 0.011514855s New is 3.48x faster
Output for 8.5.10
old: 0.033078396s new: 0.022361388s New is 1.48x faster
Output for 8.5.9
old: 0.016436414s new: 0.011888687s New is 1.38x faster
Output for 8.5.8
old: 0.024168311s new: 0.01184426s New is 2.04x faster
Output for 8.5.7
old: 0.038994297s new: 0.019416938s New is 2.01x faster
Output for 8.5.6
old: 0.018766533s new: 0.011912934s New is 1.58x faster
Output for 8.5.5
old: 0.022901768s new: 0.01722627s New is 1.33x faster
Output for 8.5.4
old: 0.033241492s new: 0.022824854s New is 1.46x faster
Output for 8.5.3
old: 0.032923353s new: 0.018185591s New is 1.81x faster
Output for 8.5.2
old: 0.025514221s new: 0.011415708s New is 2.24x faster
Output for 8.5.1
old: 0.030543282s new: 0.023370894s New is 1.31x faster
Output for 8.5.0
old: 0.018248745s new: 0.027326601s New is 0.67x faster
Output for 8.4.28
old: 0.030178574s new: 0.022790693s New is 1.32x faster
Output for 8.4.27
old: 0.032788543s new: 0.012164971s New is 2.70x faster
Output for 8.4.26
old: 0.037674557s new: 0.024166838s New is 1.56x faster
Output for 8.4.25
old: 0.034157646s new: 0.025722234s New is 1.33x faster
Output for 8.4.24
old: 0.032539036s new: 0.024157434s New is 1.35x faster
Output for 8.4.23
old: 0.027207854s new: 0.031822541s New is 0.85x faster
Output for 8.4.22
old: 0.014929953s new: 0.02106264s New is 0.71x faster
Output for 8.4.21
old: 0.02424058s new: 0.014211523s New is 1.71x faster
Output for 8.4.20
old: 0.016474001s new: 0.012199374s New is 1.35x faster
Output for 8.4.19
old: 0.015756333s new: 0.010768455s New is 1.46x faster
Output for 8.4.18
old: 0.015375302s new: 0.010879862s New is 1.41x faster
Output for 8.4.17
old: 0.015424715s new: 0.010793493s New is 1.43x faster
Output for 8.4.16
old: 0.015356742s new: 0.010841315s New is 1.42x faster
Output for 8.4.15
old: 0.01554097s new: 0.012245552s New is 1.27x faster
Output for 8.4.14
old: 0.015688041s new: 0.010943348s New is 1.43x faster
Output for 8.4.13
old: 0.01616059s new: 0.010983407s New is 1.47x faster
Output for 8.4.12
old: 0.01587525s new: 0.011179091s New is 1.42x faster
Output for 8.4.11
old: 0.016017224s new: 0.011145111s New is 1.44x faster
Output for 8.4.10
old: 0.016147962s new: 0.012072112s New is 1.34x faster
Output for 8.4.9
old: 0.015770624s new: 0.010986113s New is 1.44x faster
Output for 8.4.8
old: 0.015952076s new: 0.011153314s New is 1.43x faster
Output for 8.4.7
old: 0.015901902s new: 0.01109114s New is 1.43x faster
Output for 8.4.6
old: 0.015787038s new: 0.011355177s New is 1.39x faster
Output for 8.4.5
old: 0.016048502s new: 0.011129307s New is 1.44x faster
Output for 8.4.4
old: 0.016131577s new: 0.012495287s New is 1.29x faster
Output for 8.4.3
old: 0.015811496s new: 0.011059662s New is 1.43x faster
Output for 8.4.2
old: 0.020889368s new: 0.011472763s New is 1.82x faster
Output for 8.4.1
old: 0.015985717s new: 0.010896007s New is 1.47x faster
Output for 8.3.37
old: 0.01567399s new: 0.011210089s New is 1.40x faster
Output for 8.3.36
old: 0.015409303s new: 0.010644379s New is 1.45x faster
Output for 8.3.35
old: 0.01954481s new: 0.011813174s New is 1.65x faster
Output for 8.3.33
old: 0.015006929s new: 0.010442306s New is 1.44x faster
Output for 8.3.32
old: 0.014996631s new: 0.010707053s New is 1.40x faster
Output for 8.3.31
old: 0.014756763s new: 0.010595426s New is 1.39x faster
Output for 8.3.30
old: 0.014615941s new: 0.010484219s New is 1.39x faster
Output for 8.3.29
old: 0.014790935s new: 0.010433041s New is 1.42x faster
Output for 8.3.28
old: 0.014762441s new: 0.010540894s New is 1.40x faster
Output for 8.3.27
old: 0.015310733s new: 0.010962106s New is 1.40x faster
Output for 8.3.26
old: 0.015389912s new: 0.010873093s New is 1.42x faster
Output for 8.3.25
old: 0.015359278s new: 0.010685261s New is 1.44x faster
Output for 8.3.24
old: 0.015272907s new: 0.010854575s New is 1.41x faster
Output for 8.3.23
old: 0.017824458s new: 0.010554404s New is 1.69x faster
Output for 8.3.22
old: 0.015253949s new: 0.010510819s New is 1.45x faster
Output for 8.3.21
old: 0.014983042s new: 0.010422557s New is 1.44x faster
Output for 8.3.20
old: 0.015015221s new: 0.010683609s New is 1.41x faster
Output for 8.3.19
old: 0.015120439s new: 0.01057882s New is 1.43x faster
Output for 8.3.18
old: 0.01515446s new: 0.01049806s New is 1.44x faster
Output for 8.3.17
old: 0.015352747s new: 0.010885192s New is 1.41x faster
Output for 8.3.16
old: 0.015009091s new: 0.010771599s New is 1.39x faster
Output for 8.3.15
old: 0.015136653s new: 0.010728936s New is 1.41x faster
Output for 8.3.14
old: 0.01506175s new: 0.010480934s New is 1.44x faster
Output for 8.3.13
old: 0.015397085s new: 0.010737748s New is 1.43x faster
Output for 8.3.12
old: 0.014926388s new: 0.010460965s New is 1.43x faster
Output for 8.3.11
old: 0.015317174s new: 0.010859191s New is 1.41x faster
Output for 8.3.10
old: 0.015092416s new: 0.010543938s New is 1.43x faster
Output for 8.3.9
old: 0.015135651s new: 0.010492952s New is 1.44x faster
Output for 8.3.8
old: 0.015183442s new: 0.011672763s New is 1.30x faster
Output for 8.3.7
old: 0.016131276s new: 0.015371025s New is 1.05x faster
Output for 8.3.6
old: 0.025679329s new: 0.0171935s New is 1.49x faster
Output for 8.3.5
old: 0.017615655s new: 0.014016881s New is 1.26x faster
Output for 8.3.4
old: 0.018629507s new: 0.012547304s New is 1.48x faster
Output for 8.3.3
old: 0.018154713s new: 0.011922798s New is 1.52x faster
Output for 8.3.2
old: 0.016849494s new: 0.011727254s New is 1.44x faster
Output for 8.3.1
old: 0.017180792s new: 0.015731305s New is 1.09x faster
Output for 8.3.0
old: 0.016828222s new: 0.011788206s New is 1.43x faster
Output for 8.2.36
old: 0.016366969s new: 0.011482648s New is 1.43x faster
Output for 8.2.35
old: 0.016160158s new: 0.011321336s New is 1.43x faster
Output for 8.2.34
old: 0.016750516s new: 0.011300054s New is 1.48x faster
Output for 8.2.33
old: 0.016148373s new: 0.011343568s New is 1.42x faster
Output for 8.2.32
old: 0.017487682s new: 0.011362598s New is 1.54x faster
Output for 8.2.31
old: 0.015009071s new: 0.010594855s New is 1.42x faster
Output for 8.2.30
old: 0.01552754s new: 0.011063077s New is 1.40x faster
Output for 8.2.29
old: 0.019236298s new: 0.015603272s New is 1.23x faster
Output for 8.2.28
old: 0.016723275s new: 0.011463929s New is 1.46x faster
Output for 8.2.27
old: 0.017537066s new: 0.011553694s New is 1.52x faster
Output for 8.2.26
old: 0.01635341s new: 0.011690399s New is 1.40x faster
Output for 8.2.25
old: 0.01631356s new: 0.011545993s New is 1.41x faster
Output for 8.2.24
old: 0.016344787s new: 0.011441366s New is 1.43x faster
Output for 8.2.23
old: 0.017948544s new: 0.011751642s New is 1.53x faster
Output for 8.2.22
old: 0.016525988s new: 0.011367254s New is 1.45x faster
Output for 8.2.21
old: 0.01622703s new: 0.011441886s New is 1.42x faster
Output for 8.2.20
old: 0.018304058s new: 0.011688496s New is 1.57x faster
Output for 8.2.19
old: 0.01965785s new: 0.011756719s New is 1.67x faster
Output for 8.2.18
old: 0.016058106s new: 0.011398351s New is 1.41x faster
Output for 8.2.17
old: 0.016744406s new: 0.01181005s New is 1.42x faster
Output for 8.2.16
old: 0.029735978s new: 0.011520674s New is 2.58x faster
Output for 8.2.15
old: 0.027328716s new: 0.013263751s New is 2.06x faster
Output for 8.2.14
old: 0.016296324s new: 0.011399272s New is 1.43x faster
Output for 8.2.13
old: 0.018513773s new: 0.022211343s New is 0.83x faster
Output for 8.2.12
old: 0.016701442s new: 0.016977386s New is 0.98x faster
Output for 8.2.11
old: 0.030928339s new: 0.021297782s New is 1.45x faster
Output for 8.2.10
old: 0.031250012s new: 0.017152439s New is 1.82x faster
Output for 8.2.9
old: 0.027637449s new: 0.022565095s New is 1.22x faster
Output for 8.2.8
old: 0.033335052s new: 0.024095261s New is 1.38x faster
Output for 8.2.7
old: 0.034089004s new: 0.025483496s New is 1.34x faster
Output for 8.2.6
old: 0.036518631s new: 0.013777182s New is 2.65x faster
Output for 8.2.5
old: 0.017834523s new: 0.011017099s New is 1.62x faster
Output for 8.2.4
old: 0.036347015s new: 0.025611848s New is 1.42x faster
Output for 8.2.3
old: 0.035112792s new: 0.02133033s New is 1.65x faster
Output for 8.2.2
old: 0.024915472s new: 0.011570661s New is 2.15x faster
Output for 8.2.1
old: 0.017229364s new: 0.013617662s New is 1.27x faster
Output for 8.2.0
old: 0.031959768s new: 0.017175533s New is 1.86x faster
Output for 8.1.34
old: 0.027670158s new: 0.015325696s New is 1.81x faster
Output for 8.1.33
old: 0.01956534s new: 0.01147095s New is 1.71x faster
Output for 8.1.32
old: 0.029998864s new: 0.011089627s New is 2.71x faster
Output for 8.1.31
old: 0.035330136s new: 0.016055233s New is 2.20x faster
Output for 8.1.30
old: 0.028875697s new: 0.016399257s New is 1.76x faster
Output for 8.1.29
old: 0.019870328s new: 0.01222904s New is 1.62x faster
Output for 8.1.28
old: 0.032040008s new: 0.023920289s New is 1.34x faster
Output for 8.1.27
old: 0.018097528s new: 0.021607627s New is 0.84x faster
Output for 8.1.26
old: 0.017027732s new: 0.011747004s New is 1.45x faster
Output for 8.1.25
old: 0.0349258s new: 0.022223171s New is 1.57x faster
Output for 8.1.24
old: 0.038095228s new: 0.021628037s New is 1.76x faster
Output for 8.1.23
old: 0.034056024s new: 0.018740983s New is 1.82x faster
Output for 8.1.22
old: 0.019389477s new: 0.011009407s New is 1.76x faster
Output for 8.1.21
old: 0.017104607s new: 0.025105759s New is 0.68x faster
Output for 8.1.20
old: 0.035649306s new: 0.025804136s New is 1.38x faster
Output for 8.1.19
old: 0.026221893s new: 0.016999559s New is 1.54x faster
Output for 8.1.18
old: 0.025764536s new: 0.023104584s New is 1.12x faster
Output for 8.1.17
old: 0.035703608s new: 0.023989662s New is 1.49x faster
Output for 8.1.16
old: 0.030136591s new: 0.022940328s New is 1.31x faster
Output for 8.1.15
old: 0.017331508s new: 0.012313704s New is 1.41x faster
Output for 8.1.14
old: 0.028233263s new: 0.011632393s New is 2.43x faster
Output for 8.1.13
old: 0.036195296s new: 0.022629661s New is 1.60x faster
Output for 8.1.12
old: 0.029186995s new: 0.016420851s New is 1.78x faster
Output for 8.1.11
old: 0.016343796s new: 0.011947786s New is 1.37x faster
Output for 8.1.10
old: 0.034433711s new: 0.022352455s New is 1.54x faster
Output for 8.1.9
old: 0.028269287s new: 0.024168402s New is 1.17x faster
Output for 8.1.8
old: 0.031962551s new: 0.017400602s New is 1.84x faster
Output for 8.1.7
old: 0.033305306s new: 0.02139571s New is 1.56x faster
Output for 8.1.6
old: 0.034213501s new: 0.024039587s New is 1.42x faster
Output for 8.1.5
old: 0.032924346s new: 0.018421653s New is 1.79x faster
Output for 8.1.4
old: 0.020319824s new: 0.012173295s New is 1.67x faster
Output for 8.1.3
old: 0.028833464s new: 0.011023239s New is 2.62x faster
Output for 8.1.2
old: 0.032585246s new: 0.023401539s New is 1.39x faster
Output for 8.1.1
old: 0.031391203s new: 0.018392221s New is 1.71x faster
Output for 8.1.0
old: 0.023434109s new: 0.011159242s New is 2.10x faster
Output for 8.0.30
old: 0.022959706s new: 0.012188777s New is 1.88x faster
Output for 8.0.29
old: 0.016271077s new: 0.012037901s New is 1.35x faster
Output for 8.0.28
old: 0.01608042s new: 0.012236058s New is 1.31x faster
Output for 8.0.27
old: 0.015941582s new: 0.012012733s New is 1.33x faster
Output for 8.0.26
old: 0.017216876s new: 0.012595738s New is 1.37x faster
Output for 8.0.25
old: 0.016224897s new: 0.012069498s New is 1.34x faster
Output for 8.0.24
old: 0.016671636s new: 0.012240836s New is 1.36x faster
Output for 8.0.23
old: 0.016369644s new: 0.012079724s New is 1.36x faster
Output for 8.0.22
old: 0.016193741s new: 0.012238843s New is 1.32x faster
Output for 8.0.21
old: 0.0166871s new: 0.012215267s New is 1.37x faster
Output for 8.0.20
old: 0.016565127s new: 0.012130329s New is 1.37x faster
Output for 8.0.19
old: 0.016349824s new: 0.012241828s New is 1.34x faster
Output for 8.0.18
old: 0.016431196s new: 0.012053444s New is 1.36x faster
Output for 8.0.17
old: 0.016422173s new: 0.012216139s New is 1.34x faster
Output for 8.0.16
old: 0.016056883s new: 0.011967896s New is 1.34x faster
Output for 8.0.15
old: 0.017058897s new: 0.011553364s New is 1.48x faster
Output for 8.0.14
old: 0.015915913s new: 0.012198202s New is 1.30x faster
Output for 8.0.13
old: 0.016168843s new: 0.012175468s New is 1.33x faster
Output for 8.0.12
old: 0.016109161s new: 0.012117471s New is 1.33x faster
Output for 8.0.11
old: 0.01600778s new: 0.012024602s New is 1.33x faster
Output for 8.0.10
old: 0.031277462s new: 0.013810783s New is 2.26x faster
Output for 8.0.9
old: 0.016034742s new: 0.012132483s New is 1.32x faster
Output for 8.0.8
old: 0.016158277s new: 0.012285642s New is 1.32x faster
Output for 8.0.7
old: 0.016199118s new: 0.01226363s New is 1.32x faster
Output for 8.0.6
old: 0.016252768s new: 0.0148546s New is 1.09x faster
Output for 8.0.5
old: 0.016196824s new: 0.012379143s New is 1.31x faster
Output for 8.0.3
old: 0.018028604s new: 0.012376879s New is 1.46x faster
Output for 8.0.2
old: 0.016367471s new: 0.01351051s New is 1.21x faster
Output for 8.0.1
old: 0.016154782s new: 0.012148618s New is 1.33x faster
Output for 8.0.0
old: 0.016371137s new: 0.012014715s New is 1.36x faster

preferences:
32.02 ms | 1710 KiB | 6 Q