Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Convert Set to Array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.from()
2653.9 Ops/sec
spread operator
3057.9 Ops/sec
for...of loop
927.2 Ops/sec
iterator.next()
958.0 Ops/sec
Script Preparation code:
var testSet = new Set(); for (let i = 1; i <= 100000; i++) { testSet.add(i); }
Tests:
Array.from()
const arrayFrom = Array.from(testSet.values());
spread operator
const arraySpread = [...testSet];
for...of loop
const arrayForOf = []; for (const value of testSet) { arrayForOf.push(value); }
iterator.next()
const arrayWhileNext = []; let iterator = testSet.values(); let next = iterator.next(); while (!next.done) { arrayWhileNext.push(next.value); next = iterator.next(); }