for, for-of, forEach

Benchmark created on


Setup

const arr = new Array(2**13)
  .fill(undefined)
  .map(() => ({ value: null }));

Test runner

Ready to run.

Testing in
TestOps/sec
for
for (let i = 0; i < arr.length; i++)
  arr[i].value = Math.random();
ready
for-of
for (const node of arr)
  node.value = Math.random();
ready
forEach
arr.forEach((node) => node.value = Math.random());
ready

Revisions

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