Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.fromEntries vs for...of vs for (C style)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0
Browser:
Firefox 150
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
Object.fromEntries
754.7 Ops/sec
for...of
886.5 Ops/sec
for (C style)
865.1 Ops/sec
forEach
886.8 Ops/sec
Script Preparation code:
const data = Array(10000); for (let i=0; i<data.length; i++) { data[i] = i; }
Tests:
Object.fromEntries
const a = Object.fromEntries(data.map((idx) => ["id-"+idx, idx]));
for...of
const a = {} for (const idx of data) { a["id-"+idx] = idx; }
for (C style)
const a = {} for (let i=0; i<data.length; i++) { const idx = data[i]; a["id-"+idx] = idx; }
forEach
const a = {} data.forEach(idx => a["id-"+idx] = idx);