Two ways to set values and return

Benchmark created on


Setup

var myObject = {
      x: 3,
      y: 4
    };
    
    setIndividually = function(x, y) {
      myObject.x = x + 5 / y;
      myObject.y = y + 5 / x;
      return myObject; 
    };
    
    setTogether = function(x,y) {
      return {
        x: x + 5 / y,
        y: y + 5 / x
      };    
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Set individually
setIndividually(90, 100);
ready
Set together
setTogether(90, 100);
ready

Revisions

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