Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for-in vs object.keys vs object.values for objects without extra log
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/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
for-in
252.4 Ops/sec
Object.keys
318.1 Ops/sec
Script Preparation code:
function getObj(i) { return { 'a': { id: 'a', num: 1 }, 'b': { id: 'b', num: 1 }, 'c': { id: 'c', num: 1 }, 'd': { id: 'd', num: 1 }, 'e': { id: 'e', num: 1 }, 'f': { id: 'f', num: 1 }, 'g': { id: 'g', num: 1 }, [i.toString()]: 1, }; };
Tests:
for-in
const r = []; for (var i=10000; i > 0; i--) { for (var key in getObj(i)) { r[i] = key; } } console.log(r.length)
Object.keys
const r = []; for (var i=10000; i > 0; i--) { Object.keys(getObj(i)).forEach(key => { r[i] = key; }); } console.log(r.length)