object access; direct vs. indirect

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    o1 = {indirect:{x:3, y:4}};
    o2 = o1.indirect;
    var x=0, y=0, z=0, w=0;
};
</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
Direct
 y+= o2.x + o2.y
 x+= o2.x + o2.y
 w+= o2.x + o2.y
 z+= o2.x + o2.y
pending…
Indirect
 y+= o1.indirect.x + o1.indirect.y
x+= o1.indirect.x + o1.indirect.y
z+=o1.indirect.x + o1.indirect.y
w+=o1.indirect.x + o1.indirect.y
pending…
Creation
var o3 = o1.indirect;
 y+= o3.x + o3.y
x+=o3.x + o3.y
z+=o3.x + o3.y
w+=o3.x + o3.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