for of Set vs for of Array.from(Set)

Benchmark created on


Setup

const size = 1_000_000;
const mySet = new Set(Array.from({length: size}, (_, i) => i));

Test runner

Ready to run.

Testing in
TestOps/sec
for of Set
let sum1 = 0;
for (const item of mySet) {
  sum1 += item;
}
ready
for of Array.from(Set)
let sum2 = 0;
for (const item of Array.from(mySet)) {
  sum2 += item;
}
ready

Revisions

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