Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Populating a Set
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Map
55144.3 Ops/sec
Loop
143741.3 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const make = (length) => ({ id: length, items: Array.from({ length }, () => make(length / 2)) }) const data = make(20)
Tests:
Map
const ids = Array.from(new Set( data.items.map( i => i.items.map( ii => ii.items ) ).flat(2) .filter(item => item.id % 2 === 0) .map(item => item.id.toString()) ))
Loop
const items = new Set() for (const i of data.items) for (const ii of i.items) for (const item of ii.items) if (item.id % 2 === 0) items.add(item.id.toString()) const ids = Array.from(items)