3v4l.org

run code in 500+ PHP versions simultaneously
<?php function truncate(string &$text): void { if (is_numeric($text)) { $text = ltrim($text, '0'); } if (mb_strlen($text) <= 50) { return; } $text = mb_substr($text, 0, 50); } function truncate2(string &$text): void { if (is_numeric($text)) { $text = ltrim($text, '0'); } $text = mb_substr($text, 0, 50); } $x = 'fdbvfgbtrbwrbtrbrtwb'; $before = microtime(true); for ($i=0 ; $i<10000 ; $i++) { truncate($x); } $after = microtime(true); echo ($after-$before) . " sec\n"; $before = microtime(true); for ($i=0 ; $i<10000 ; $i++) { truncate2($x); } $after = microtime(true); echo ($after-$before) . " sec\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 7
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 26
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 26
Branch analysis from position: 32
Branch analysis from position: 26
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 7
Branch analysis from position: 13
Branch analysis from position: 7
filename:       /in/MVdrk
function name:  (null)
number of ops:  40
compiled vars:  !0 = $x, !1 = $before, !2 = $i, !3 = $after
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                       !0, 'fdbvfgbtrbwrbtrbrtwb'
   22     1        INIT_FCALL                                                   'microtime'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !1, $5
   24     5        ASSIGN                                                       !2, 0
          6      > JMP                                                          ->11
   25     7    >   INIT_FCALL                                                   'truncate'
          8        SEND_REF                                                     !0
          9        DO_FCALL                                          0          
   24    10        PRE_INC                                                      !2
         11    >   IS_SMALLER                                                   !2, 10000
         12      > JMPNZ                                                        ~10, ->7
   28    13    >   INIT_FCALL                                                   'microtime'
         14        SEND_VAL                                                     <true>
         15        DO_ICALL                                             $11     
         16        ASSIGN                                                       !3, $11
   29    17        SUB                                                  ~13     !3, !1
         18        CONCAT                                               ~14     ~13, '+sec%0A'
         19        ECHO                                                         ~14
   32    20        INIT_FCALL                                                   'microtime'
         21        SEND_VAL                                                     <true>
         22        DO_ICALL                                             $15     
         23        ASSIGN                                                       !1, $15
   34    24        ASSIGN                                                       !2, 0
         25      > JMP                                                          ->30
   35    26    >   INIT_FCALL                                                   'truncate2'
         27        SEND_REF                                                     !0
         28        DO_FCALL                                          0          
   34    29        PRE_INC                                                      !2
         30    >   IS_SMALLER                                                   !2, 10000
         31      > JMPNZ                                                        ~20, ->26
   38    32    >   INIT_FCALL                                                   'microtime'
         33        SEND_VAL                                                     <true>
         34        DO_ICALL                                             $21     
         35        ASSIGN                                                       !3, $21
   39    36        SUB                                                  ~23     !3, !1
         37        CONCAT                                               ~24     ~23, '+sec%0A'
         38        ECHO                                                         ~24
         39      > RETURN                                                       1

Function truncate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/MVdrk
function name:  truncate
number of ops:  21
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        FRAMELESS_ICALL_1                is_numeric          ~1      !0
          2      > JMPZ                                                         ~1, ->8
    5     3    >   INIT_FCALL                                                   'ltrim'
          4        SEND_VAR                                                     !0
          5        SEND_VAL                                                     '0'
          6        DO_ICALL                                             $2      
          7        ASSIGN                                                       !0, $2
    7     8    >   INIT_FCALL                                                   'mb_strlen'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                             $4      
         11        IS_SMALLER_OR_EQUAL                                          $4, 50
         12      > JMPZ                                                         ~5, ->14
    8    13    > > RETURN                                                       null
   10    14    >   INIT_FCALL                                                   'mb_substr'
         15        SEND_VAR                                                     !0
         16        SEND_VAL                                                     0
         17        SEND_VAL                                                     50
         18        DO_ICALL                                             $6      
         19        ASSIGN                                                       !0, $6
   11    20      > RETURN                                                       null

End of function truncate

Function truncate2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/MVdrk
function name:  truncate2
number of ops:  15
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        FRAMELESS_ICALL_1                is_numeric          ~1      !0
          2      > JMPZ                                                         ~1, ->8
   15     3    >   INIT_FCALL                                                   'ltrim'
          4        SEND_VAR                                                     !0
          5        SEND_VAL                                                     '0'
          6        DO_ICALL                                             $2      
          7        ASSIGN                                                       !0, $2
   17     8    >   INIT_FCALL                                                   'mb_substr'
          9        SEND_VAR                                                     !0
         10        SEND_VAL                                                     0
         11        SEND_VAL                                                     50
         12        DO_ICALL                                             $4      
         13        ASSIGN                                                       !0, $4
   18    14      > RETURN                                                       null

End of function truncate2

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.31 ms | 493 KiB | 13 Q