Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Map: Native vs Lodash vs Rambda vs Sanctuary
(version: 5)
Comparing performance of:
Native vs Lodash vs Rambda vs Sanctuary
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://unpkg.com/lodash@4.17.11/lodash.min.js"></script> <script src="https://unpkg.com/rambdax@2.8.1/dist/rambdax.umd.js"></script> <script src="https://unpkg.com/sanctuary-show@1.0.0/index.js"></script> <script src="https://unpkg.com/sanctuary-type-identifiers@2.0.1/index.js"></script> <script src="https://unpkg.com/sanctuary-type-classes@9.0.0/index.js"></script> <script src="https://unpkg.com/sanctuary-either@1.0.0/index.js"></script> <script src="https://unpkg.com/sanctuary-maybe@1.0.0/index.js"></script> <script src="https://unpkg.com/sanctuary-pair@1.0.0/index.js"></script> <script src="https://unpkg.com/sanctuary-def@0.18.1/index.js"></script> <script src="https://unpkg.com/sanctuary@0.15.0/index.js"></script>
Script Preparation code:
function double(n) { return n*2; } var data = [...Array(20)].map((v, idx) => idx); const S = sanctuary.create({ checkTypes: localStorage.getItem ('SANCTUARY_CHECK_TYPES') === 'true', env: sanctuary.env, }); var sanct = S.map(double)
Tests:
Native
data.map(double);
Lodash
_.map(data, double);
Rambda
R.map(double, data);
Sanctuary
sanct(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Native
Lodash
Rambda
Sanctuary
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser/OS:
Chrome 123 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native
4977613.0 Ops/sec
Lodash
7352540.5 Ops/sec
Rambda
7784672.5 Ops/sec
Sanctuary
3424660.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what is being tested. **Benchmark Definition** The benchmark measures the performance of four different functions: `double`, which multiplies its input by 2, and three map functions (`map`, `_.map`, and `R.map`) that apply this multiplication to an array of numbers. The map functions are from the Lodash, Rambda, and Sanctuary libraries, respectively. **Options Compared** The benchmark compares the performance of four different approaches: 1. **Native**: The native JavaScript implementation, which uses the built-in `map` function. 2. **Lodash**: The `_map` function from the Lodash library, a popular utility library for functional programming in JavaScript. 3. **Rambda**: The `R.map` function from the Rambda library, another utility library for functional programming in JavaScript. 4. **Sanctuary**: The `sanct` function from the Sanctuary library, which is designed to provide a more expressive and type-safe way of working with data. **Pros and Cons** Here are some pros and cons of each approach: * **Native**: + Pros: Fastest execution time, most efficient use of resources. + Cons: May not be as expressive or convenient to use as other libraries. * **Lodash**: + Pros: Convenient and expressive API, widely used and well-maintained library. + Cons: May have a slight performance overhead due to the extra indirection. * **Rambda**: + Pros: Concise and expressive API, good balance between convenience and performance. + Cons: Less widely used than Lodash, may have less support and documentation. * **Sanctuary**: + Pros: Provides a more expressive and type-safe way of working with data, which can lead to better code quality and fewer bugs. + Cons: May have a slight performance overhead due to the extra indirection. **Library Descriptions** Here's a brief description of each library: * **Lodash**: A popular utility library for functional programming in JavaScript. It provides a wide range of functions for working with arrays, objects, and other data structures. * **Rambda**: A concise and expressive API library that aims to provide a more functional programming style than Lodash. It's designed to be fast and efficient while still being easy to use. * **Sanctuary**: A library that provides a type-safe and expressive way of working with data. It's designed to help developers write better code by providing a more explicit and declarative API. **Other Considerations** When choosing between these libraries, consider the following factors: * **Performance**: If you need the fastest execution time, Native may be the best choice. If performance is not as critical, Lodash or Rambda may be a good option. * **Convenience**: If you want a convenient and expressive API, Lodash or Sanctuary may be a good choice. * **Code quality**: If you want to write better code with fewer bugs, Sanctuary's type-safe approach may be the best choice. **Alternatives** If you're looking for alternative libraries, consider the following options: * **Ramda**: A functional programming library that provides a concise and expressive API similar to Rambda. * **Immutable.js**: A library that provides a way to work with immutable data structures in JavaScript. It's designed to be fast and efficient while still being easy to use. * **Puredocs**: A library that provides a type-safe and expressive way of working with data, similar to Sanctuary. I hope this explanation helps!
Related benchmarks:
Map - Native vs Lodash vs Ramda vs Sanctuary
Map - Native vs Lodash vs Ramda vs Sanctuary 10,000
Map (Native vs Ramda vs Lodash) latest 2021-01-18
Map (Native vs Ramda 0.27.2 vs Lodash 4.17.21) 50k
Comments
Confirm delete:
Do you really want to delete benchmark?