Access or pass

JavaScript performance comparison

Test case created by Michael Poland

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    Vector3 = function(_x, _y, _z) {
      return {
        x: _x,
        y: _y,
        z: _z
      };
    };
   
    camera = {};
    camera.position = Vector3(Math.random(), Math.random(), Math.random());
   
    function access() {
      var c = camera.position;
      return c.x + "," + c.y + "," + c.x;
    }
   
    function pass(x,y,z) {
      return x + "," + y + "," + z;
    }
};
</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
Access
access();
pending…
Pass
var x = camera.position.x;
var y = camera.position.y;
var z = camera.position.z;
pass(x,y,z);
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