Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array ops - for-each vs double map-filter
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/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
For-Each
16524.3 Ops/sec
map + filter twice
20373.1 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() {}
Tests:
For-Each
const exampleObjects = Array.from(Array(1000)).map((_, i) => { const randomId = Math.round(Math.random() * 100); const otherRandomId = Math.round(Math.random() * 100); return { objectId: i % 3 === 0 ? undefined : randomId.toString(), clientObjectId: i % 4 === 0 ? undefined : otherRandomId.toString(), } }); const objectIds = new Set(exampleObjects.map(i => i.objectId).filter(i => i !== undefined)); const clientObjectIds = new Set(exampleObjects.map(i => i.clientObjectId).filter(i => i !== undefined));
map + filter twice
const exampleObjects = Array.from(Array(1000)).map((_, i) => { const randomId = Math.round(Math.random() * 100); const otherRandomId = Math.round(Math.random() * 100); return { objectId: i % 3 === 0 ? undefined : randomId.toString(), clientObjectId: i % 4 === 0 ? undefined : otherRandomId.toString(), } }); const objectIds = new Set(); const clientObjectIds = new Set(); for (const i of exampleObjects) { if (i.objectId) objectIds.add(i.objectId); if (i.clientObjectId) clientObjectIds.add(i.clientObjectId); }