Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find by id and replace in array [lodash vs js vs ramda]
find by id and replace in array [lodash vs js vs ramda]
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/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
es6 map
21.6M/s
ramda map
6.1M/s
lodash findIndex and splice
4.4M/s
ramda findIndex and splice
2.1M/s
lodash map
940K/s
View exact numbers
Test name
Executions per second
✓
es6 map
21,623,322 Ops/sec
ramda map
6,118,124 Ops/sec
lodash findIndex and splice
4,391,646 Ops/sec
ramda findIndex and splice
2,112,233 Ops/sec
lodash map
939,514 Ops/sec
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/lodash-fp/0.10.4/lodash-fp.min.js"></script>
Script Preparation code:
var arr = [{id: 1, name: "Person 1"}, {id: 2, name: "Person 2"}];
Tests:
lodash map
var newArr = _.map(arr, function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; });
es6 map
// ES6 var newArr = arr.map(function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; });
lodash findIndex and splice
var index = _.findIndex(arr, {id: 1}); // Replace item at index using native splice arr.splice(index, 1, {id: 100, name: 'Person New Name'});
ramda findIndex and splice
const index = R.findIndex(R.propEq('id', 1))(arr) arr.splice(index, 1, {id: 100, name: 'Person New Name'});
ramda map
var newArr = R.map(function(a) { return a.id === 1 ? {id: 1, name: "Person New Name"} : a; })(arr);