bit-multiply

JavaScript performance comparison

Revision 5 of this test case created

Preparation code

<script>
var ESCAPE = function () { };
</script>
<script>
Benchmark.prototype.setup = function() {
    function multiply(x,y) {
        return x*y;
    }
   
    function multiply_uint32(a, b) {
        var ah = (a >> 16) & 0xffff, al = a & 0xffff;
        var bh = (b >> 16) & 0xffff, bl = b & 0xffff;
        var high = ((ah * bl) + (al * bh)) & 0xffff;
        return ((high << 16)>>>0) + (al * bl);
    }
   
    var a1 = Math.random()*10000000000 | 0,
        b1 = Math.random()*10000000000 | 0,
        a2 = Math.random()*10000000000 | 0,
        b2 = Math.random()*10000000000 | 0,
        c1, c2;
   
};

Benchmark.prototype.teardown = function() {
    ESCAPE(c1, c2, a1, a2, b1, b2, a, b);
};
</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
multiply
var a = a1, b = b1;
a1 = a2; b1 = b2; a2 = a; b2 = b;

c1 = multiply(a1, b1);
c2 = multiply(a2, b2);
 
pending…
multiply_uint32
var a = a1, b = b1;
a1 = a2; b1 = b2; a2 = a; b2 = b;

c1 = multiply_uint32(a1, b1);
c2 = multiply_uint32(a2, b2);
 
pending…
imul
var a = a1, b = b1;
a1 = a2; b1 = b2; a2 = a; b2 = b;

c1 = Math.imul(a1, b1);
c2 = Math.imul(a2, b2);
pending…
baseline
var a = a1, b = b1;
a1 = a2; b1 = b2; a2 = a; b2 = b;
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