object vs arguments
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
withObject |
|
pending… |
withArguments |
|
pending… |
withArgumentsReturnsArray |
|
pending… |
withObjectReturnsArray |
|
pending… |
withObjectInplace |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments