Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash pick vs native using reduce
(version: 1)
Comparing performance of:
lodash pick vs native based on reduce
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
var arr = []; var object = { type: 'aaa', subtype: 'bbb', card_last4:'bbb', card_type:'bbb', card_exp_month:'bbb', card_exp_year:'bbb', card_country:'bbb', foo: 'bar' }; for (var i = 0; i <= 100000; i++) { arr.push(object); }
Tests:
lodash pick
arr.map(el => _.pick(el, ['type', 'subtype', 'card_last4', 'card_type', 'card_exp_month', 'card_exp_year', 'card_country']));
native based on reduce
function pick(object, keys) { return keys.reduce((obj, key) => { if (object && object.hasOwnProperty(key)) { obj[key] = object[key]; } return obj; }, {}); } arr.map(el => pick(el, ['type', 'subtype', 'card_last4', 'card_type', 'card_exp_month', 'card_exp_year', 'card_country']));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash pick
native based on reduce
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash pick
10.9 Ops/sec
native based on reduce
62.9 Ops/sec
Related benchmarks:
Lodash Pick vs Native destructuring vs Manual Picks
Lodash Pick vs Native destructuring vs Manual
Lodash Pick vs compiled pick fn
Lodash Pick vs compiled pick fn vs loop pick fn
Lodash Pick vs Native destructuring vs Manual Picks1
Lodash pick and native method
Lodash pick and native method 1
Lodash pick vs native
Lodash pick vs native pick
Comments
Confirm delete:
Do you really want to delete benchmark?