Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash chunk
(version: 0)
Comparing performance of:
Lodash vs Native
Created:
5 years ago
by:
Registered User
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 data = [1,3,2,1,4,5,6,7,8,9,0]
Tests:
Lodash
_.chunk(data,2);
Native
const chunk = (arr, size) => Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => arr.slice(i * size, i * size + size) ); chunk(data,2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0
Browser/OS:
Firefox 144 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
13757599.0 Ops/sec
Native
10954177.0 Ops/sec
Autogenerated LLM Summary
(model
gemma2:9b
, generated one year ago):
This benchmark compares the performance of two methods for chunking an array in JavaScript: **Options Compared:** 1. **Lodash:** Uses the `_.chunk()` function from the Lodash library. 2. **Native:** Implements the chunking logic using native JavaScript array methods (`slice`, `ceil`, and `Array.from`). **Pros and Cons:** * **Lodash:** * **Pros:** Concise, potentially optimized for performance by Lodash's developers. * **Cons:** Introduces an external dependency (Lodash), which adds size to the application and could have potential conflicts with other libraries. * **Native:** * **Pros:** No external dependencies, relies on core JavaScript functionality, generally more performant in cases where micro-optimizations are minimal. * **Cons:** Can be less concise than using a library function like `_.chunk()`. Requires writing the logic yourself, potentially introducing minor errors if not implemented carefully. **Library Description:** Lodash is a popular JavaScript utility library that provides a wide range of functions for common programming tasks, including array manipulation, object operations, string processing, and more. **Other Considerations:** * **Data Size:** The benchmark's effectiveness depends on the size of the `data` array. With very small arrays, the performance difference might be negligible. * **Optimization Level:** Both Lodash and the native implementation could have internal optimizations that affect performance differently depending on JavaScript engine and runtime environment. **Alternatives:** Besides Lodash, there are other libraries like Ramda or Underscore.js that offer similar array manipulation functions. You could also explore custom implementations using techniques like `for` loops and `splice`. Let me know if you have any further questions.
Related benchmarks:
lodash slice
Last Lodash Test
native slice vs lodash slice
native slice vs lodash slice 1M
native-slice-vs-chunk
Comments
Confirm delete:
Do you really want to delete benchmark?