bit-multiply

JavaScript performance comparison

Test case created

Preparation code

 
<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);
    }
   
};
</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 = Math.round(Math.random()*100),
    b = Math.round(Math.random()*100);

for(var i = 0; i < 10000; i++) {
   multiply(a,b);
}
pending…
multiply_uint32
var a = Math.round(Math.random()*100),
    b = Math.round(Math.random()*100);

for(var i = 0; i < 10000; i++) {
   multiply_uint32(a,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