for-of-vs-for-loop (v3)

Revision 3 of this benchmark created on


Setup

this.vals = "x".repeat(1000).split("").map((_, i) => i);

Test runner

Ready to run.

Testing in
TestOps/sec
for-of
const collected = [];
for (const value of this.vals) {
  collected.push({ value: value });
}
collected.length = this.vals.length;

 
ready
for-loop
const collected = [];

for (var i = 0; i < this.vals.length; i++) {
  const value = this.vals[i];
  collected.push({ value: value });
}
collected.length = this.vals.length;

 
ready

Revisions

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