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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.675 YaBrowser/23.11.1.675 (beta) Yowser/2.5 Safari/537.36
Browser:
Yandex Browser 23
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
es6 map
34.8M/s
ramda map
9.2M/s
lodash findIndex and splice
6.5M/s
ramda findIndex and splice
2.8M/s
lodash map
1.3M/s
View exact numbers
Test name
Executions per second
✓
es6 map
34,836,280 Ops/sec
ramda map
9,159,159 Ops/sec
lodash findIndex and splice
6,478,202 Ops/sec
ramda findIndex and splice
2,825,902 Ops/sec
lodash map
1,262,996 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);