Recursion vs non recursion

JavaScript performance comparison

Test case created

Preparation code

<script>
function divideRecursive(numerator, denominator) {
        if (numerator < denominator) {
                return 0;
        }
        return (1 + divideRecursive(numerator - denominator, denominator));
}

function divideNonRecursive(numerator, denominator) {
   var result = 0;
   while (numerator >= denominator && numerator > 0) {
       numerator-=denominator;
       result++;
   }
   return result;
}
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Recursive
divideRecursive(100000, 25)
pending…
Non Recursive
divideNonRecursive(100000, 25)
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment