Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map initialisation
measure map initialization with array or map
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/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
.forEach()
1904344.9 Ops/sec
.map()
1710895.9 Ops/sec
Script Preparation code:
var arr = [ { a: 'Ghkfj', b: 'Yvtzq', c: 'Rwsde' }, { a: 'Bpqwm', b: 'Sdfgh', c: 'Zxcvb' }, { a: 'Olmnp', b: 'Iujkl', c: 'Qwerty' }, { a: 'Cdsaf', b: 'Asdfg', c: 'Xcvbn' }, { a: 'Qwerz', b: 'Cvbnm', c: 'Xcvbn' } ]
Tests:
.forEach()
const map = new Map(); arr.forEach(el => map.set(el.a, el));
.map()
const map = new Map(arr.map(el => [el.a, el]));