3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Start set_time_limit(0); echo "<pre>"; // Normal Recusion function m1($num) { return $num === 0 ? 1 : $num * m1($num - 1); } // Tail Recusion function m2($num) { return m2Helper($num, 1); } // Tail Recusion Helper function m2Helper($num, $acc) { return $num === 0 ? $acc : m2($num - 1, $acc * $num); } $result = array('m1' => 0,'m2' => 0); $no = 100; for($i = 0; $i < 1; ++ $i) { foreach ( array_keys($result) as $key ) { $alpha = microtime(true); $key($no); $result[$key] += microtime(true) - $alpha; } } echo '<pre>'; echo "Single Run\n"; print_r($result); echo '</pre>'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
Branch analysis from position: 8
Branch analysis from position: 27
filename:       /in/o5lHE
function name:  (null)
number of ops:  38
compiled vars:  !0 = $result, !1 = $no, !2 = $i, !3 = $key, !4 = $alpha
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'set_time_limit'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    4     3        ECHO                                                     '%3Cpre%3E'
   21     4        ASSIGN                                                   !0, <array>
   22     5        ASSIGN                                                   !1, 100
   23     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->29
   24     8    >   INIT_FCALL                                               'array_keys'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $9      
         11      > FE_RESET_R                                       $10     $9, ->27
         12    > > FE_FETCH_R                                               $10, !3, ->27
   25    13    >   INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !4, $11
   26    17        INIT_DYNAMIC_CALL                                        !3
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0          
   27    20        INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $15     
         23        SUB                                              ~16     $15, !4
         24        ASSIGN_DIM_OP                +=               1          !0, !3
         25        OP_DATA                                                  ~16
   24    26      > JMP                                                      ->12
         27    >   FE_FREE                                                  $10
   23    28        PRE_INC                                                  !2
         29    >   IS_SMALLER                                               !2, 1
         30      > JMPNZ                                                    ~18, ->8
   31    31    >   ECHO                                                     '%3Cpre%3E'
   32    32        ECHO                                                     'Single+Run%0A'
   33    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                                 
   34    36        ECHO                                                     '%3C%2Fpre%3E'
   35    37      > RETURN                                                   1

Function m1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
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: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5lHE
function name:  m1
number of ops:  13
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        IS_IDENTICAL                                             !0, 0
          2      > JMPZ                                                     ~1, ->5
          3    >   QM_ASSIGN                                        ~2      1
          4      > JMP                                                      ->11
          5    >   INIT_FCALL_BY_NAME                                       'm1'
          6        SUB                                              ~3      !0, 1
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0  $4      
          9        MUL                                              ~5      !0, $4
         10        QM_ASSIGN                                        ~2      ~5
         11    > > RETURN                                                   ~2
    9    12*     > RETURN                                                   null

End of function m1

Function m2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5lHE
function name:  m2
number of ops:  7
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL_BY_NAME                                       'm2Helper'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              1
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   14     6*     > RETURN                                                   null

End of function m2

Function m2helper:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o5lHE
function name:  m2Helper
number of ops:  15
compiled vars:  !0 = $num, !1 = $acc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        IS_IDENTICAL                                             !0, 0
          3      > JMPZ                                                     ~2, ->6
          4    >   QM_ASSIGN                                        ~3      !1
          5      > JMP                                                      ->13
          6    >   INIT_FCALL                                               'm2'
          7        SUB                                              ~4      !0, 1
          8        SEND_VAL                                                 ~4
          9        MUL                                              ~5      !1, !0
         10        SEND_VAL                                                 ~5
         11        DO_FCALL                                      0  $6      
         12        QM_ASSIGN                                        ~3      $6
         13    > > RETURN                                                   ~3
   19    14*     > RETURN                                                   null

End of function m2helper

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.61 ms | 1407 KiB | 22 Q