Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for..of against Map.entries vs for..in 2
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
for..of Map.entries()
6619.3 Ops/sec
Map.foreach
7144.4 Ops/sec
for..of Map.entries() no destructuring
7287.5 Ops/sec
Script Preparation code:
var array = Array.from({ length: 10000 }, () => { const n = Math.floor(Math.random() * 100) if (n > 26) { return n } else { return String.fromCharCode('a'.charCodeAt(0) + n); } }); var obj = new Map(); for (let i = 0; i < array.length; i++) { obj.set(i, array[i]); }
Tests:
for..of Map.entries()
for (const [key, val] of obj.entries()) { const foo = val + 'a'; }
Map.foreach
obj.forEach((val) => { const foo = val + 'a'; })
for..of Map.entries() no destructuring
for (const entry of obj.entries()) { const key = entry[0]; const val = entry[1]; const foo = val + 'a'; }