object vs arguments

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    obj = {x: 10, y: 10}
   
    function withObject(obj) {
       return {x : obj.x + 10, y : obj.y + 10};
    }
   
    function withObjectReturnsArray(obj) {
       return [obj.x + 10, obj.y + 10];
    }
   
    function withObjectInplace(obj) {
       obj.x = obj.x + 10; obj.y = obj.y + 10;
       return obj;
    }
   
    function withArgumentsReturnsArray(x, y) {
       return [x + 10, y + 10];
    }
   
    function withArguments(x, y) {
       return {x: x + 10, y: y + 10};
    }
};
</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
withObject
withObject(obj);
pending…
withArguments
withArguments(10, 10);
pending…
withArgumentsReturnsArray
withArgumentsReturnsArray(10, 10);
pending…
withObjectReturnsArray
withObjectReturnsArray(10, 10);
pending…
withObjectInplace
withObjectInplace(obj);
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