separate vs. combined assignment

Benchmark created by rhill on


Preparation HTML

<script>
  function Separate() {
   this.a = 0;
   this.b = 0;
   this.c = 0;
   this.d = 0;
   this.e = 0;
  }
  Separate.prototype.do = function(v) {
   this.a = v;
   this.b = v;
   this.c = v;
   this.d = v;
   this.e = v;
  };
  var separate = new Separate();
  
  function Combined() {
   this.a = this.b = this.c = this.d = this.e = 0;
  }
  Combined.prototype.do = function(v) {
   this.a = this.b = this.c = this.d = this.e = v;
  };
  var combined = new Combined();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
separate
separate.do(1);
separate.do(10);
separate.do(100);
separate.do(1000);
separate.do(10000);
ready
combined
combined.do(1);
combined.do(10);
combined.do(100);
combined.do(1000);
combined.do(10000);
ready

Revisions

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