Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
remove child dacre
(version: 0)
Comparing performance of:
Lodash.js filter vs native
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var max1 = 1000; // 100,000 (100 Thousand) var max2 = 10; var childUids = []; for (var i = 0; i <= max1; i++) { childUids.push(i); } var childUidsToRemove = []; for (var i = 0; i <= max2; i++) { childUidsToRemove.push(i); }
Tests:
Lodash.js filter
childUidsToRemove.forEach((childUid) => { _.remove(childUids, (uid) => uid === childUid); });
native
Array.from( childUidsToRemove.reduce((set, childUid) => { set.delete(childUid); return set; }, new Set(childUids)), );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash.js filter
native
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/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash.js filter
89326.5 Ops/sec
native
53657.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what's being tested. **Benchmark Definition** The benchmark is defined by two scripts: `Script Preparation Code` and `Html Preparation Code`. The first script creates two arrays, `childUids` and `childUidsToRemove`, with a large number of elements (1000 and 10, respectively). These arrays are then used in the individual test cases. **Individual Test Cases** There are two test cases: 1. **Lodash.js filter**: This test case uses the Lodash library to remove elements from the `childUids` array using the `remove` function. 2. **native**: This test case uses native JavaScript methods (Array.prototype.filter() and Array.prototype.reduce()) to achieve a similar result. **Options Compared** The benchmark compares two approaches: 1. **Lodash.js filter**: Using a library like Lodash can provide a convenient and efficient way to perform array operations. However, it may introduce additional overhead due to the library's existence. 2. **native**: This approach relies on built-in JavaScript methods, which are typically faster and more lightweight than using an external library. **Pros and Cons** * **Lodash.js filter**: + Pros: Convenient, efficient, and easy to use for array operations. + Cons: Introduces additional overhead due to the library's existence. * **native**: + Pros: Typically faster, more lightweight, and reduces dependencies on external libraries. + Cons: Requires a deeper understanding of native JavaScript methods. **Library Used** In this benchmark, Lodash is used. Lodash is a popular utility library that provides a wide range of functions for tasks such as array manipulation, string manipulation, and object manipulation. The `remove` function in this case is used to remove elements from the `childUids` array based on a condition. **Special JS Feature or Syntax** There are no special JavaScript features or syntaxes used in these test cases. They rely solely on standard JavaScript methods. **Other Alternatives** If you wanted to implement this benchmark using different approaches, here are some alternatives: 1. **Use a different library**: Instead of Lodash, you could use another utility library like Underscore.js or a custom implementation. 2. **Use other native methods**: You could experiment with alternative native JavaScript methods for array operations, such as `Array.prototype.map()`, `Array.prototype.forEach()`, or `Array.prototype.every()`. 3. **Use a different data structure**: Instead of using arrays, you could use objects or sets to store the child UIDs and implement the removal logic accordingly. Keep in mind that these alternatives might change the benchmark's behavior and results.
Related benchmarks:
Test uuidv1 vs uuidv4
[sited] Lodash vs native map
[sited] Lodash vs native reduce
Set string vs number
Set string vs number (100k)
Comments
Confirm delete:
Do you really want to delete benchmark?