3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Most likely front-end 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() { /** * 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.018593357s new: 0.011880428s New is 1.57x faster
Output for 8.5.13
old: 0.016486092s new: 0.008723207s New is 1.89x faster
Output for 8.5.12
old: 0.018364693s new: 0.008763918s New is 2.10x faster
Output for 8.5.11
old: 0.016408876s new: 0.009174294s New is 1.79x faster
Output for 8.5.10
old: 0.021003564s new: 0.008766553s New is 2.40x faster
Output for 8.5.9
old: 0.01621836s new: 0.008919672s New is 1.82x faster
Output for 8.5.8
old: 0.018213557s new: 0.008544058s New is 2.13x faster
Output for 8.5.7
old: 0.020232227s new: 0.009359352s New is 2.16x faster
Output for 8.5.6
old: 0.019869452s new: 0.009951702s New is 2.00x faster
Output for 8.5.5
old: 0.018504703s new: 0.008636968s New is 2.14x faster
Output for 8.5.4
old: 0.017058782s new: 0.009558232s New is 1.78x faster
Output for 8.5.3
old: 0.012804163s new: 0.007940271s New is 1.61x faster
Output for 8.5.2
old: 0.013547329s new: 0.007074071s New is 1.92x faster
Output for 8.5.1
old: 0.014025578s new: 0.007116405s New is 1.97x faster
Output for 8.5.0
old: 0.018276882s new: 0.009333593s New is 1.96x faster
Output for 8.4.28
old: 0.015336206s new: 0.007811898s New is 1.96x faster
Output for 8.4.27
old: 0.017452332s new: 0.009167483s New is 1.90x faster
Output for 8.4.26
old: 0.013816955s new: 0.007270566s New is 1.90x faster
Output for 8.4.25
old: 0.015194594s new: 0.007962956s New is 1.91x faster
Output for 8.4.24
old: 0.017991572s new: 0.007555384s New is 2.38x faster
Output for 8.4.23
old: 0.013862402s new: 0.007717327s New is 1.80x faster
Output for 8.4.22
old: 0.01362067s new: 0.007904558s New is 1.72x faster
Output for 8.4.21
old: 0.017362729s new: 0.009058622s New is 1.92x faster
Output for 8.4.20
old: 0.014514261s new: 0.008486241s New is 1.71x faster
Output for 8.4.19
old: 0.014055644s new: 0.007454524s New is 1.89x faster
Output for 8.4.18
old: 0.014778769s new: 0.007792779s New is 1.90x faster
Output for 8.4.17
old: 0.014378347s new: 0.007761233s New is 1.85x faster
Output for 8.4.16
old: 0.014714423s new: 0.008016957s New is 1.84x faster
Output for 8.4.15
old: 0.017650691s new: 0.008996068s New is 1.96x faster
Output for 8.4.14
old: 0.017970872s new: 0.009273173s New is 1.94x faster
Output for 8.4.13
old: 0.017919344s new: 0.009138421s New is 1.96x faster
Output for 8.4.12
old: 0.013985298s new: 0.008333682s New is 1.68x faster
Output for 8.4.11
old: 0.016302247s new: 0.008370877s New is 1.95x faster
Output for 8.4.10
old: 0.018169048s new: 0.009288486s New is 1.96x faster
Output for 8.4.9
old: 0.018652937s new: 0.009347795s New is 2.00x faster
Output for 8.4.8
old: 0.014150856s new: 0.008247263s New is 1.72x faster
Output for 8.4.7
old: 0.01579891s new: 0.008153452s New is 1.94x faster
Output for 8.4.6
old: 0.014438108s new: 0.007117086s New is 2.03x faster
Output for 8.4.5
old: 0.016154424s new: 0.007522694s New is 2.15x faster
Output for 8.4.4
old: 0.016214404s new: 0.007826201s New is 2.07x faster
Output for 8.4.3
old: 0.014824778s new: 0.007894854s New is 1.88x faster
Output for 8.4.2
old: 0.016313543s new: 0.008283457s New is 1.97x faster
Output for 8.4.1
old: 0.018699656s new: 0.0095718s New is 1.95x faster
Output for 8.3.37
old: 0.017951083s new: 0.012785466s New is 1.40x faster
Output for 8.3.36
old: 0.015492461s new: 0.008563747s New is 1.81x faster
Output for 8.3.35
old: 0.017586053s new: 0.009306102s New is 1.89x faster
Output for 8.3.33
old: 0.020749573s new: 0.008801636s New is 2.36x faster
Output for 8.3.32
old: 0.023248927s new: 0.009792191s New is 2.37x faster
Output for 8.3.31
old: 0.019605165s new: 0.008660573s New is 2.26x faster
Output for 8.3.30
old: 0.015626081s new: 0.008476377s New is 1.84x faster
Output for 8.3.29
old: 0.01672495s new: 0.008266171s New is 2.02x faster
Output for 8.3.28
old: 0.018770702s new: 0.008247502s New is 2.28x faster
Output for 8.3.27
old: 0.017279785s new: 0.00911712s New is 1.90x faster
Output for 8.3.26
old: 0.021303635s new: 0.009692873s New is 2.20x faster
Output for 8.3.25
old: 0.015855184s new: 0.008522416s New is 1.86x faster
Output for 8.3.24
old: 0.016092302s new: 0.008933954s New is 1.80x faster
Output for 8.3.23
old: 0.020885108s new: 0.008057316s New is 2.59x faster
Output for 8.3.22
old: 0.020761151s new: 0.012306697s New is 1.69x faster
Output for 8.3.21
old: 0.014303897s new: 0.007869395s New is 1.82x faster
Output for 8.3.20
old: 0.015259381s new: 0.008552951s New is 1.78x faster
Output for 8.3.19
old: 0.017050701s new: 0.007895856s New is 2.16x faster
Output for 8.3.18
old: 0.015812281s new: 0.008337498s New is 1.90x faster
Output for 8.3.17
old: 0.016298791s new: 0.011066727s New is 1.47x faster
Output for 8.3.16
old: 0.015884579s new: 0.008642376s New is 1.84x faster
Output for 8.3.15
old: 0.021280151s new: 0.008613763s New is 2.47x faster
Output for 8.3.14
old: 0.018032854s new: 0.009258551s New is 1.95x faster
Output for 8.3.13
old: 0.020801041s new: 0.011074926s New is 1.88x faster
Output for 8.3.12
old: 0.018582421s new: 0.008860583s New is 2.10x faster
Output for 8.3.11
old: 0.016616108s new: 0.00881901s New is 1.88x faster
Output for 8.3.10
old: 0.01973502s new: 0.011874269s New is 1.66x faster
Output for 8.3.9
old: 0.016874555s new: 0.010563601s New is 1.60x faster
Output for 8.3.8
old: 0.021814533s new: 0.008655375s New is 2.52x faster
Output for 8.3.7
old: 0.017019623s new: 0.009021365s New is 1.89x faster
Output for 8.3.6
old: 0.018873848s new: 0.008670808s New is 2.18x faster
Output for 8.3.5
old: 0.019843584s new: 0.007988884s New is 2.48x faster
Output for 8.3.4
old: 0.018707828s new: 0.009501785s New is 1.97x faster
Output for 8.3.3
old: 0.016422797s new: 0.008736527s New is 1.88x faster
Output for 8.3.2
old: 0.017346895s new: 0.009032461s New is 1.92x faster
Output for 8.3.1
old: 0.023129746s new: 0.009154435s New is 2.53x faster
Output for 8.3.0
old: 0.018516441s new: 0.009542717s New is 1.94x faster
Output for 8.2.36
old: 0.018213555s new: 0.011234047s New is 1.62x faster
Output for 8.2.35
old: 0.022371289s new: 0.01170876s New is 1.91x faster
Output for 8.2.34
old: 0.018494649s new: 0.008348144s New is 2.22x faster
Output for 8.2.33
old: 0.018737262s new: 0.009833494s New is 1.91x faster
Output for 8.2.32
old: 0.015665781s new: 0.008559421s New is 1.83x faster
Output for 8.2.31
old: 0.022376517s new: 0.012685446s New is 1.76x faster
Output for 8.2.30
old: 0.019478023s new: 0.010110701s New is 1.93x faster
Output for 8.2.29
old: 0.023151892s new: 0.009712562s New is 2.38x faster
Output for 8.2.28
old: 0.020419539s new: 0.009175868s New is 2.23x faster
Output for 8.2.27
old: 0.020430103s new: 0.008218009s New is 2.49x faster
Output for 8.2.26
old: 0.020440691s new: 0.00887245s New is 2.30x faster
Output for 8.2.25
old: 0.030896578s new: 0.009665282s New is 3.20x faster
Output for 8.2.24
old: 0.018877743s new: 0.010697382s New is 1.76x faster
Output for 8.2.23
old: 0.016630358s new: 0.011155019s New is 1.49x faster
Output for 8.2.22
old: 0.018816191s new: 0.010426484s New is 1.80x faster
Output for 8.2.21
old: 0.021037227s new: 0.007780732s New is 2.70x faster
Output for 8.2.20
old: 0.017401207s new: 0.008763207s New is 1.99x faster
Output for 8.2.19
old: 0.024494667s new: 0.008704739s New is 2.81x faster
Output for 8.2.18
old: 0.028436385s new: 0.017605462s New is 1.62x faster
Output for 8.2.17
old: 0.026317984s new: 0.011160427s New is 2.36x faster
Output for 8.2.16
old: 0.029768065s new: 0.010818613s New is 2.75x faster
Output for 8.2.15
old: 0.017520175s new: 0.008743027s New is 2.00x faster
Output for 8.2.14
old: 0.017477961s new: 0.008734915s New is 2.00x faster
Output for 8.2.13
old: 0.017588157s new: 0.009139152s New is 1.92x faster
Output for 8.2.12
old: 0.018426976s new: 0.0078721s New is 2.34x faster
Output for 8.2.11
old: 0.01850253s new: 0.010061506s New is 1.84x faster
Output for 8.2.10
old: 0.017409329s new: 0.008705921s New is 2.00x faster
Output for 8.2.9
old: 0.018665124s new: 0.009273483s New is 2.01x faster
Output for 8.2.8
old: 0.01917559s new: 0.0102909s New is 1.86x faster
Output for 8.2.7
old: 0.014115403s new: 0.007669947s New is 1.84x faster
Output for 8.2.6
old: 0.017461326s new: 0.008553072s New is 2.04x faster
Output for 8.2.5
old: 0.016260825s new: 0.007215133s New is 2.25x faster
Output for 8.2.4
old: 0.014821404s new: 0.008202215s New is 1.81x faster
Output for 8.2.3
old: 0.015773653s new: 0.008399991s New is 1.88x faster
Output for 8.2.2
old: 0.018869431s new: 0.008371919s New is 2.25x faster
Output for 8.2.1
old: 0.01842918s new: 0.009429426s New is 1.95x faster
Output for 8.2.0
old: 0.01525282s new: 0.007809685s New is 1.95x faster
Output for 8.1.34
old: 0.017884633s new: 0.009439242s New is 1.89x faster
Output for 8.1.33
old: 0.015757127s new: 0.007943987s New is 1.98x faster
Output for 8.1.32
old: 0.018226425s new: 0.010115718s New is 1.80x faster
Output for 8.1.31
old: 0.015656816s new: 0.008159401s New is 1.92x faster
Output for 8.1.30
old: 0.015446962s new: 0.007864006s New is 1.96x faster
Output for 8.1.29
old: 0.017774458s new: 0.009338361s New is 1.90x faster
Output for 8.1.28
old: 0.015039901s new: 0.00761233s New is 1.98x faster
Output for 8.1.27
old: 0.017781048s new: 0.008526181s New is 2.09x faster
Output for 8.1.26
old: 0.015183717s new: 0.00705367s New is 2.15x faster
Output for 8.1.25
old: 0.014138648s new: 0.007493671s New is 1.89x faster
Output for 8.1.24
old: 0.015613622s new: 0.008158229s New is 1.91x faster
Output for 8.1.23
old: 0.018169419s new: 0.009204871s New is 1.97x faster
Output for 8.1.22
old: 0.014644358s new: 0.008216256s New is 1.78x faster
Output for 8.1.21
old: 0.014575674s new: 0.008417689s New is 1.73x faster
Output for 8.1.20
old: 0.013593781s new: 0.007449506s New is 1.82x faster
Output for 8.1.19
old: 0.014723295s new: 0.007112398s New is 2.07x faster
Output for 8.1.18
old: 0.015260183s new: 0.007834784s New is 1.95x faster
Output for 8.1.17
old: 0.014047031s new: 0.009377659s New is 1.50x faster
Output for 8.1.16
old: 0.014225657s new: 0.00815886s New is 1.74x faster
Output for 8.1.15
old: 0.015782565s new: 0.011044403s New is 1.43x faster
Output for 8.1.14
old: 0.019318024s new: 0.009628106s New is 2.01x faster
Output for 8.1.13
old: 0.014593662s new: 0.007863135s New is 1.86x faster
Output for 8.1.12
old: 0.014278408s new: 0.008087233s New is 1.77x faster
Output for 8.1.11
old: 0.015414574s new: 0.00728599s New is 2.12x faster
Output for 8.1.10
old: 0.014378849s new: 0.007906912s New is 1.82x faster
Output for 8.1.9
old: 0.015410708s new: 0.007466211s New is 2.06x faster
Output for 8.1.8
old: 0.018043241s new: 0.010662859s New is 1.69x faster
Output for 8.1.7
old: 0.020931918s new: 0.00917813s New is 2.28x faster
Output for 8.1.6
old: 0.015457338s new: 0.008373682s New is 1.85x faster
Output for 8.1.5
old: 0.021150106s new: 0.009281515s New is 2.28x faster
Output for 8.1.4
old: 0.017968428s new: 0.00918516s New is 1.96x faster
Output for 8.1.3
old: 0.013855803s new: 0.007676116s New is 1.81x faster
Output for 8.1.2
old: 0.018028097s new: 0.009651611s New is 1.87x faster
Output for 8.1.1
old: 0.016956169s new: 0.00815883s New is 2.08x faster
Output for 8.1.0
old: 0.017905894s new: 0.009633514s New is 1.86x faster
Output for 8.0.30
old: 0.017972123s new: 0.009168626s New is 1.96x faster
Output for 8.0.29
old: 0.018167617s new: 0.010570932s New is 1.72x faster
Output for 8.0.28
old: 0.018008097s new: 0.010558983s New is 1.71x faster
Output for 8.0.27
old: 0.01835615s new: 0.011118284s New is 1.65x faster
Output for 8.0.26
old: 0.018934348s new: 0.010741267s New is 1.76x faster
Output for 8.0.25
old: 0.015129917s new: 0.00846538s New is 1.79x faster
Output for 8.0.24
old: 0.017861727s new: 0.010378543s New is 1.72x faster
Output for 8.0.23
old: 0.014471948s new: 0.008467513s New is 1.71x faster
Output for 8.0.22
old: 0.016092732s new: 0.009323089s New is 1.73x faster
Output for 8.0.21
old: 0.014457477s new: 0.009154735s New is 1.58x faster
Output for 8.0.20
old: 0.01831616s new: 0.010438752s New is 1.75x faster
Output for 8.0.19
old: 0.013978379s new: 0.007994963s New is 1.75x faster
Output for 8.0.18
old: 0.015190036s new: 0.008207904s New is 1.85x faster
Output for 8.0.17
old: 0.015877308s new: 0.009107054s New is 1.74x faster
Output for 8.0.16
old: 0.014889745s new: 0.008079311s New is 1.84x faster
Output for 8.0.15
old: 0.018001297s new: 0.01022356s New is 1.76x faster
Output for 8.0.14
old: 0.01398683s new: 0.008167374s New is 1.71x faster
Output for 8.0.13
old: 0.014610837s new: 0.007597788s New is 1.92x faster
Output for 8.0.12
old: 0.015702676s new: 0.008807693s New is 1.78x faster
Output for 8.0.11
old: 0.018084082s new: 0.010406484s New is 1.74x faster
Output for 8.0.10
old: 0.014183727s new: 0.009075977s New is 1.56x faster
Output for 8.0.9
old: 0.015456276s new: 0.008911099s New is 1.73x faster
Output for 8.0.8
old: 0.015299491s new: 0.009040063s New is 1.69x faster
Output for 8.0.7
old: 0.018061748s new: 0.01042344s New is 1.73x faster
Output for 8.0.6
old: 0.018344593s new: 0.010951943s New is 1.68x faster
Output for 8.0.5
old: 0.014871558s new: 0.008524719s New is 1.74x faster
Output for 8.0.3
old: 0.015912732s new: 0.008332491s New is 1.91x faster
Output for 8.0.2
old: 0.015658379s new: 0.008575905s New is 1.83x faster
Output for 8.0.1
old: 0.018896412s new: 0.008855837s New is 2.13x faster
Output for 8.0.0
old: 0.015294523s new: 0.00845226s New is 1.81x faster

preferences:
32.6 ms | 1710 KiB | 6 Q