_.pick vs entries |> filter

Benchmark created on


Preparation HTML

<script src="
https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js
"></script>

Setup

const data = [...Array(100).keys().map(i => ({ a: 1, b: 2, c: 3 }))];
const fields = ['a', 'c'];

Test runner

Ready to run.

Testing in
TestOps/sec
_.pick
_.pick(data, fields);
ready
Object.entries().filter()
data.map(d => Object.fromEntries(Object.entries(d).filter(([key]) => fields.includes(key))))
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.