Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs Lodash vs Native : Remove selected values
(version: 1)
Comparing performance of:
Ramda vs Lodash vs Native
Created:
5 years ago
by:
Registered User
Jump to the latest result
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.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
var array = ['a', 'b', 'c', 'a', 'b', 'c'];
Tests:
Ramda
_.pull(array, 'a', 'c');
Lodash
_.pull(array, 'a', 'c');
Native
array = [...new Set(array)];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Ramda
Lodash
Native
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!
Autogenerated LLM Summary
(model
llama3.1:latest
, generated one year ago):
Let's break down the benchmark test case by case. **Benchmark Name and Description** The benchmark is called "Ramda vs Lodash vs Native : Remove selected values". The description is not provided, but based on the test cases, it appears to be comparing three approaches to remove specific values from an array: 1. Using Ramda (a JavaScript library for functional programming) 2. Using Lodash (another popular JavaScript library) 3. A native JavaScript implementation **Test Case 1: Ramda** The benchmark definition is `_.pull(array, 'a', 'c');` and the test name is "Ramda". This means that we're using Ramda's `_pull()` function to remove the values `'a'` and `'c'` from the array. Here's what's happening: * We're creating an array `[ 'a', 'b', 'c', 'a', 'b', 'c' ]` * We're using Ramda's `_pull()` function, which takes two arguments: the array to modify and the values to remove * The resulting array will be `[ 'b', 'b' ]`, as both `'a'` and `'c'` are removed Ramda is a popular JavaScript library for functional programming. It provides a wide range of useful functions, including `_pull()`. In this case, it's being used to remove specific values from an array. **Test Case 2: Lodash** The benchmark definition is also `_.pull(array, 'a', 'c');` and the test name is "Lodash". This means that we're using Lodash's `_pull()` function to remove the same values as in Test Case 1. Here's what's happening: * We're creating an array `[ 'a', 'b', 'c', 'a', 'b', 'c' ]` * We're using Lodash's `_pull()` function, which takes two arguments: the array to modify and the values to remove * The resulting array will be `[ 'b', 'b' ]`, as both `'a'` and `'c'` are removed Lodash is another popular JavaScript library that provides a wide range of useful functions. In this case, it's being used to remove specific values from an array. **Test Case 3: Native** The benchmark definition is `array = [...new Set(array)];` and the test name is "Native". This means that we're using a native JavaScript implementation to remove duplicate values from the array. Here's what's happening: * We're creating an array `[ 'a', 'b', 'c', 'a', 'b', 'c' ]` * We're using the `Set` object to create a new set from the array. The `Set` object is an unordered collection of unique values. * We're spreading the set back into an array using the spread operator (`[...set]`). This will remove duplicate values, leaving us with `[ 'a', 'b', 'c' ]` The native JavaScript implementation uses built-in features like `Set` and the spread operator to achieve the same result as Ramda or Lodash. **Benchmark Results** The latest benchmark results show that: * Ramda performs best (2957867.25 executions per second) * Lodash comes next (2402574.0 executions per second) * Native JavaScript implementation is the slowest (463455.03125 executions per second) This suggests that using a library like Ramda or Lodash can provide performance benefits when removing specific values from an array, compared to a native JavaScript implementation. **Alternatives** Other alternatives for removing duplicate values from an array include: * Using `Array.prototype.filter()` with a custom callback function * Using `Array.prototype.reduce()` to create a new array without duplicates * Using a third-party library like underscore.js or Immutable.js Keep in mind that these alternatives may have different performance characteristics and trade-offs compared to the native JavaScript implementation or popular libraries like Ramda and Lodash.
Related benchmarks:
lodash includes vs ramda includes
Lodash isEmpty vs native .isArray + length
Lodash vs Ramda vs Native fromPairs
Last element (Native vs Ramda vs Lodash)
Comments
Confirm delete:
Do you really want to delete benchmark?