object vs positional args

JavaScript performance comparison

Test case created by thoughtspile

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const objGreet = ops => 'hello, ' + ops.name + '!';
  const posGreet = (name) => 'hello, ' + name + '!';
  const greet = { name: 'petya' };
  const pyGreet = (name, ops) => {
    return ((ops && ops.lang === 'fr') ? 'bonjour,' : 'hello, ') + name + '!';
  };

};
</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: 'ivan' });
pending…
Cached object
objGreet(greet);
pending…
Positional
posGreet('ivan')
pending…
kwargs ops unused
pyGreet('Vladimir')
pending…
kwargs ops used
pyGreet('Vladimir', { lang: 'fr' })
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