Object Overhead (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var a = [1,2,3];
  var b = [4,6,7];
  
  function V(u) {
  this.x = u[1];
  this.y = u[1];
  this.z = u[2];
  }
  
  V.prototype = {
  dot: function (w) {
  return this.x*w.x+this.y*w.y+this.z*w.z;
  },
  cross: function (w) {
  return [
  this.y*w.z-this.z*w.y,
  this.z*w.x-this.x*w.z,
  this.x*w.y-this.y*w.x
  ];
  }
  };
  
  var A = new V(a);
  var B = new V(b);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object
var C = A.cross(B);
ready
No Object
var c = [a[1]*b[2]-a[2]*b[1],
a[2]*b[0]-a[0]*b[2],
a[0]*b[1]-a[1]*b[0]];
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.