Execute queue: arrow function v. apply

Benchmark created on


Setup

var words = ['this', 'is', 'a', 'test'];
  
  var counter = 0;
  var length = 100;
  var queue = [];
  
  var text = ''

Test runner

Ready to run.

Testing in
TestOps/sec
Arrow function
for(let i = 0; i < length; i++) {
  queue.push(() => words[i & 3] + (counter++));
}
for (const task of queue) {
  text += task();
}
ready
Array + apply
const f = function(a, b) {
	return a + b;
}
for(let i = 0; i < length; ++i) {
  queue.push([f, null, [words[i & 3], counter++]]);
}
for (const task of queue) {
  text += task[0].apply(task[1], task[2]);
}

ready
Not lazy
for(let i = 0; i < length; i++) {
  text += words[i & 3] + (counter++);
}

ready

Revisions

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