integer exponentiation

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function fastPow(n, x) {
      return x == 2 ? n * n : Math.pow(n, x);
    }
};
</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
Exp by squaring
for(var x, i = 0; i < 100000; i++)
    x = fastPow(i, 2);
pending…
Math.pow
for(var x, i = 0; i < 100000; i++)
    x = Math.pow(i, 2);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment