for-of-vs-for-loop (v2)

Revision 2 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
var collected = [];
var active = this.vals.slice(100);
for (var value of active) {
  collected.push({ value: value });
}
collected.length = this.vals.length;

 
ready
for-loop
var collected = [];
var length = this.vals.length;
var value = 0;

for (var i = 100; i < length; i++) {
  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.