something with packing ints

JavaScript performance comparison

Test case created by Arnor

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var pack = function(o) { return o.x ? (o.x | o.y << 16) : {y: ((o & 0xffff0000) >>> 16), x: o & 0xffff }; }
   
    var a = {x: 1337, y: 8888};
   
    var b = pack(a);
   
};
</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
looking up an object hash
var new = {x: a.x + 58, y: a.y + 83};
 
pending…
packing an int
var new = pack({x: pack(b).x + 58, y: pack(b).y});
pending…
packing an int 2
var k = pack(b);
var new = pack({x: k.x + 58, y: k.y});
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