Function reference performance math functions

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var max=Math.max;
    var abs=Math.abs;
    var c=-10;
    var d= 3;
    function absCustom(x)
    {
    return x>0?x:-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
Math.max
var a = Math.max(10,20);
pending…
max
var a = max(10,20);
pending…
Math.abs
var a = Math.abs(c)
var b = Math.abs(d)
pending…
abs
var a = abs(c)
var b = abs(d)
pending…
abs
var a = c>0?c:-c;
var b = d>0?d:-d;
pending…
absCustom
var a = absCustom(c)
var b = absCustom(d)
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