The first two tests show that function recursion is slightly faster with native subroutine variables instead of with user variables. That's not surprising, because there is more overhead in using user variables.
It's also not surprising that function recursion is faster than subroutine recursion. Though I do wonder why it's by such a high margin. I had to reduce the countdown by a factor of 10 just to test subroutine recursion speed, and it still took more time than function recursion. While using a user variable may be a factor, it is even slower than the coontduwn function that uses user variables.
What is surprising is the last result, which shows that a do loop was slower than function recursion. The countdown is the same, but the loop took more time.
Here's a result I find surprising. First the code I ran:
Then the results:
The first two tests show that function recursion is slightly faster with native subroutine variables instead of with user variables. That's not surprising, because there is more overhead in using user variables.
It's also not surprising that function recursion is faster than subroutine recursion. Though I do wonder why it's by such a high margin. I had to reduce the countdown by a factor of 10 just to test subroutine recursion speed, and it still took more time than function recursion. While using a user variable may be a factor, it is even slower than the coontduwn function that uses user variables.
What is surprising is the last result, which shows that a do loop was slower than function recursion. The countdown is the same, but the loop took more time.