Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Reduce + for of vs Map and nested for of
(version: 3)
Comparing performance of:
Reduce + for of vs Map, nested for of + Object.fromEntries
Created:
4 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = [ { fields: { internalName: "__NAME__", targetCategoryId: ["1", "2", "3", "4"], textColor: "#FFFFFF" }, }, { fields: { internalName: "__NAME__", targetCategoryId: ["1", "2", "3", "4"], textColor: "#FFFFFF" }, }, ];
Tests:
Reduce + for of
(() => { return data.reduce( (acc, cur) => { for (const id of cur.fields.targetCategoryId) { acc[id] = { textColor: cur.fields.textColor }; } return acc; }, {}, ); })();
Map, nested for of + Object.fromEntries
(() => { const configurationMap = new Map(); for (const configuration of data) { for (const id of configuration.fields.targetCategoryId) { configurationMap.set(id, { textColor: configuration.fields.textColor }); } } return Object.fromEntries(configurationMap); })();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Reduce + for of
Map, nested for of + Object.fromEntries
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Reduce + for of
10526387.0 Ops/sec
Map, nested for of + Object.fromEntries
3553924.0 Ops/sec
Related benchmarks:
testqwe
loop test regex
Spread vs if/else
Spread vs if/else vs switch/break
1232121
2132111
1232132112
String Comparison Test
For Push vs Map Test Oke
Comments
Confirm delete:
Do you really want to delete benchmark?