object vs positional args ( numbers )

JavaScript performance comparison

Test case created by Ollink

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let counter = 0;  
  const objGreet = ops => 'hello, ' + ops.name + '!';
    const posGreet = (name) => 'hello, ' + name + '!';
   const objAdd = ops => counter += 1 + ops.name + 2;
  const posAdd = name => counter += 1 + name + 2;
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Inline object
objGreet({ name: 4 });
pending…
Positional
posGreet(4)
pending…
Positional add
posAdd(4)
pending…
Inline object add
objAdd({name : 4 })
pending…

Compare results of other browsers

Revisions

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

0 Comments