powerRecursive
JavaScript performance comparison
Info
Test recursive power function versus iterative
Preparation code
<script>
function power(base, exponent) {
return exponent == 0? 1 : base * power(base, exponent - 1);
}
function powerNR(base, exp) {
var result = 1;
while(exp--) {
result *= base;
}
return result;
}
var x = 5, y = 11;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Recursive |
|
pending… |
Iterative |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments