Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
_.pickBy vs native vs ES6 Filter
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/126.0.0.0 Safari/537.36 Edg/126.0.0.0
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash pickBy
33437.0 Ops/sec
Native Filter
44087.6 Ops/sec
ES6 Filter
9517.6 Ops/sec
Script Preparation code:
var obj = {}; for (let i = 0; i < 1000; i++) { const randomNum = Math.floor(Math.random() * 4); obj[i.toString()] = randomNum === 0 ? "undefined" : randomNum === 1 ? false : true; }
Tests:
Lodash pickBy
_.pickBy(obj);
Native Filter
function pickBy(object) { const obj = {}; for (const key in object) { if (object[key]) { obj[key] = object[key]; } } return obj; } pickBy(obj)
ES6 Filter
Object.keys(obj).filter(key => { if (obj[key]) return obj[key] })