callback with or without context

Benchmark created on


Setup

const nodes = Array.from({ length: 100000 }, () => Math.random());
const callback = function() {}
const length = nodes.length;

Test runner

Ready to run.

Testing in
TestOps/sec
callback()
for(let i = 0; i < length; i++) {
  const node = nodes[i];
  callback(node, i);
}
ready
callback.call()
for(let i = 0; i < length; i++) {
  const node = nodes[i];
  callback.call(node, node, i);
}
ready
callback.bind()
for(let i = 0; i < length; i++) {
  const node = nodes[i];
  callback.bind(node)(node, i);
}
ready

Revisions

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