3v4l.org

run code in 500+ PHP versions simultaneously
<?php $cnt = 1000; $strs = [ 'empty' => '', 'short' => 'zluty kun', 'short_with_uc' => 'zluty Kun', 'long' => str_repeat('this is about 10000 chars long string', 270), 'long_with_uc' => str_repeat('this is about 10000 chars long String', 270), 'short_utf8' => 'žlutý kůň', 'short_utf8_with_uc' => 'Žlutý kŮň', ]; foreach ($strs as $k => $str) { $a1 = microtime(true); for($i=0; $i < $cnt; ++$i){ $res = strtolower($str); } $t1 = microtime(true) - $a1; // echo 'it took ' . round($t1 * 1000, 3) . ' ms for ++$i'."\n"; $a2 = microtime(true); for($i=0; $i < $cnt; $i++){ $res = mb_strtolower($str); } $t2 = microtime(true) - $a2; // echo 'it took ' . round($t2 * 1000, 3) . ' ms for $i++'."\n"; echo 'strtolower is '.round($t2/$t1, 2).'x faster than mb_strtolower for ' . $k . "\n\n"; }

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 67
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 67
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 26
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 44
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 44
Branch analysis from position: 51
Branch analysis from position: 44
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 26
Branch analysis from position: 33
Branch analysis from position: 26
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
filename:       /in/bOdXP
function name:  (null)
number of ops:  69
compiled vars:  !0 = $cnt, !1 = $strs, !2 = $str, !3 = $k, !4 = $a1, !5 = $i, !6 = $res, !7 = $t1, !8 = $a2, !9 = $t2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 1000
    6     1        INIT_ARRAY                                           ~11     '', 'empty'
    7     2        ADD_ARRAY_ELEMENT                                    ~11     'zluty+kun', 'short'
    8     3        ADD_ARRAY_ELEMENT                                    ~11     'zluty+Kun', 'short_with_uc'
    9     4        INIT_FCALL                                                   'str_repeat'
          5        SEND_VAL                                                     'this+is+about+10000+chars+long+string'
          6        SEND_VAL                                                     270
          7        DO_ICALL                                             $12     
          8        ADD_ARRAY_ELEMENT                                    ~11     $12, 'long'
   10     9        INIT_FCALL                                                   'str_repeat'
         10        SEND_VAL                                                     'this+is+about+10000+chars+long+String'
         11        SEND_VAL                                                     270
         12        DO_ICALL                                             $13     
         13        ADD_ARRAY_ELEMENT                                    ~11     $13, 'long_with_uc'
   11    14        ADD_ARRAY_ELEMENT                                    ~11     '%C5%BElut%C3%BD+k%C5%AF%C5%88', 'short_utf8'
   12    15        ADD_ARRAY_ELEMENT                                    ~11     '%C5%BDlut%C3%BD+k%C5%AE%C5%88', 'short_utf8_with_uc'
    5    16        ASSIGN                                                       !1, ~11
   15    17      > FE_RESET_R                                           $15     !1, ->67
         18    > > FE_FETCH_R                                           ~16     $15, !2, ->67
         19    >   ASSIGN                                                       !3, ~16
   16    20        INIT_FCALL                                                   'microtime'
         21        SEND_VAL                                                     <true>
         22        DO_ICALL                                             $18     
         23        ASSIGN                                                       !4, $18
   17    24        ASSIGN                                                       !5, 0
         25      > JMP                                                          ->31
   18    26    >   INIT_FCALL                                                   'strtolower'
         27        SEND_VAR                                                     !2
         28        DO_ICALL                                             $21     
         29        ASSIGN                                                       !6, $21
   17    30        PRE_INC                                                      !5
         31    >   IS_SMALLER                                                   !5, !0
         32      > JMPNZ                                                        ~24, ->26
   20    33    >   INIT_FCALL                                                   'microtime'
         34        SEND_VAL                                                     <true>
         35        DO_ICALL                                             $25     
         36        SUB                                                  ~26     $25, !4
         37        ASSIGN                                                       !7, ~26
   23    38        INIT_FCALL                                                   'microtime'
         39        SEND_VAL                                                     <true>
         40        DO_ICALL                                             $28     
         41        ASSIGN                                                       !8, $28
   24    42        ASSIGN                                                       !5, 0
         43      > JMP                                                          ->49
   25    44    >   INIT_FCALL                                                   'mb_strtolower'
         45        SEND_VAR                                                     !2
         46        DO_ICALL                                             $31     
         47        ASSIGN                                                       !6, $31
   24    48        PRE_INC                                                      !5
         49    >   IS_SMALLER                                                   !5, !0
         50      > JMPNZ                                                        ~34, ->44
   27    51    >   INIT_FCALL                                                   'microtime'
         52        SEND_VAL                                                     <true>
         53        DO_ICALL                                             $35     
         54        SUB                                                  ~36     $35, !8
         55        ASSIGN                                                       !9, ~36
   30    56        INIT_FCALL                                                   'round'
         57        DIV                                                  ~38     !9, !7
         58        SEND_VAL                                                     ~38
         59        SEND_VAL                                                     2
         60        DO_ICALL                                             $39     
         61        CONCAT                                               ~40     'strtolower+is+', $39
         62        CONCAT                                               ~41     ~40, 'x+faster+than+mb_strtolower+for+'
         63        CONCAT                                               ~42     ~41, !3
         64        CONCAT                                               ~43     ~42, '%0A%0A'
         65        ECHO                                                         ~43
   15    66      > JMP                                                          ->18
         67    >   FE_FREE                                                      $15
   31    68      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.55 ms | 3232 KiB | 18 Q