Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object filter mappingv3
benchmark comparing the perf of creating a new object by filter out entries
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
Browser:
Firefox 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
object.entries
27795.5 Ops/sec
object.keys
18085.0 Ops/sec
Script Preparation code:
function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < 5; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } window.parentObj = {}; for (let i = 0; i < 1000; i++) { window.parentObj[makeid()] = makeid(); }
Tests:
object.entries
const entries = Object.entries(window.parentObj).filter(([k, v], i) => ((i % 2) === 0)); if(entries.length > 0) Object.fromEntries(entries);
object.keys
const keys = Object.keys(window.parentObj).reduce((acc, k, i) => { if ((i % 2) === 0) { acc[k] = window.parentObj[k]; } return acc }, {}); if(Object.keys(keys).length > 0) true;