3v4l.org

run code in 300+ PHP versions simultaneously
<?php function count_digits($digit) { // TODO: add type validation return $digit >= 10 ? 1 + count_digits($digit / 10) : 1; } $digit = 1554; $tries = 10000; $start = microtime(true); for ($i = 0; $i < $tries; $i++) { count_digits($digit); } echo (microtime(true) - $start).PHP_EOL; $start = microtime(true); for ($i = 0; $i < $tries; $i++) { strlen($digit); } echo (microtime(true) - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 26
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 26
Branch analysis from position: 31
Branch analysis from position: 26
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/mHGk5
function name:  (null)
number of ops:  37
compiled vars:  !0 = $digit, !1 = $tries, !2 = $start, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 1554
    9     1        ASSIGN                                                   !1, 10000
   11     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
   12     6        ASSIGN                                                   !3, 0
          7      > JMP                                                      ->12
   13     8    >   INIT_FCALL                                               'count_digits'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0          
   12    11        PRE_INC                                                  !3
         12    >   IS_SMALLER                                               !3, !1
         13      > JMPNZ                                                    ~11, ->8
   15    14    >   INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $12     
         17        SUB                                              ~13     $12, !2
         18        CONCAT                                           ~14     ~13, '%0A'
         19        ECHO                                                     ~14
   17    20        INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $15     
         23        ASSIGN                                                   !2, $15
   18    24        ASSIGN                                                   !3, 0
         25      > JMP                                                      ->29
   19    26    >   STRLEN                                           ~18     !0
         27        FREE                                                     ~18
   18    28        PRE_INC                                                  !3
         29    >   IS_SMALLER                                               !3, !1
         30      > JMPNZ                                                    ~20, ->26
   21    31    >   INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $21     
         34        SUB                                              ~22     $21, !2
         35        ECHO                                                     ~22
         36      > RETURN                                                   1

Function count_digits:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mHGk5
function name:  count_digits
number of ops:  13
compiled vars:  !0 = $digit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    5     1        IS_SMALLER_OR_EQUAL                                      10, !0
          2      > JMPZ                                                     ~1, ->10
          3    >   INIT_FCALL_BY_NAME                                       'count_digits'
          4        DIV                                              ~2      !0, 10
          5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0  $3      
          7        ADD                                              ~4      1, $3
          8        QM_ASSIGN                                        ~5      ~4
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~5      1
         11    > > RETURN                                                   ~5
    6    12*     > RETURN                                                   null

End of function count_digits

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.18 ms | 1403 KiB | 16 Q