Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
new Set from Map<number, number[]> - for..of vs Array.from(...).flat();
Comparing set creation from nested arrays using
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
for..of
665522.1 Ops/sec
Array.from().flat()
508007.9 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = new Map([ [100, [101, 102, 103, 104, 105]], [200, [201, 202, 203, 204, 205]], [300, [301, 302, 303, 304, 305]], [400, [401, 402, 403, 404, 405]], [500, [501, 502, 503, 504, 505]], ]);
Tests:
for..of
const set = new Set(); for (const ids of data.values()) { for (const id of ids) { set.add(id); } }
Array.from().flat()
const set = new Set(Array.from(data.values()).flat());