Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map vs find
(version: 0)
Comparing performance of:
map vs find
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var addons = [ { id: "a", price: 10000 }, { id: "b", price: 10000 }, { id: "c", price: 10000 }, { id: "d", price: 10000 } ]; var checkoutAddons = { a: 3, d: 2 };
Tests:
map
const map = _.mapKeys(addons, "id"); const result = _.mapValues( checkoutAddons, (quantity, id) => quantity * map[id].price );
find
const result = _.mapValues(checkoutAddons, (quantity, id) => { return quantity * _.find(addons, ["id", id]).price; }); console.log(result);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
map
find
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array.prototype.map vs Lodash.map on large data
lodash map vs native map with check
array.map vs _.map
lodash _.map vs native map
lodash _.map vs native map true version
Comments
Confirm delete:
Do you really want to delete benchmark?