Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash inRange vs JS inRange
(version: 0)
Comparing performance of:
Lodash inRange vs JS inRange
Created:
5 years ago
by:
Guest
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 inRange = (num, rangeStart, rangeEnd = 0) => (rangeStart < num && num < rangeEnd) || (rangeEnd < num && num < rangeStart);
Tests:
Lodash inRange
_.inRange(5, 0, 50); _.inRange(500, 0, 50); _.inRange(500, 0, 500); _.inRange(445, 0, 450); _.inRange(25, 0, 150); _.inRange(0, 0, 5); _.inRange(1, 0, 1); _.inRange(2, 0, 2);
JS inRange
inRange(5, 0, 50); inRange(500, 0, 50); inRange(500, 0, 500); inRange(445, 0, 450); inRange(25, 0, 150); inRange(0, 0, 5); inRange(1, 0, 1); inRange(2, 0, 2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash inRange
JS inRange
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
Lodash inRange
1069852.1 Ops/sec
JS inRange
2597914.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the explanation of the provided JSON benchmark. **Benchmark Overview** The benchmark compares the performance of two different implementations of the `inRange` function: one using Lodash, a popular JavaScript utility library, and another implemented directly in plain JavaScript. **Options Compared** The benchmark tests the following options: 1. **Lodash `inRange`**: This is a pre-built implementation of the `inRange` function provided by the Lodash library. 2. **Plain JavaScript `inRange`**: This is an implementation of the `inRange` function written from scratch in plain JavaScript. **Pros and Cons** ### Lodash `inRange` Pros: * **Maintained**: Lodash is a well-maintained and widely-used library, ensuring that the `inRange` implementation is reliable. * **Optimized**: The implementation is likely to be optimized for performance, as it's part of a larger library. Cons: * **Additional dependency**: The benchmark requires the Lodash library to be included, which adds an extra dependency and potential overhead. * **Size overhead**: Including the entire Lodash library might result in a smaller footprint compared to a custom implementation. ### Plain JavaScript `inRange` Pros: * **No additional dependencies**: This implementation doesn't require any external libraries, making it a more lightweight option. * **Customizable**: The benchmark can be easily modified or extended by modifying the plain JavaScript implementation. Cons: * **Development effort**: Creating an optimized and reliable implementation from scratch requires significant development effort. * **Less maintainable**: A custom implementation might not receive the same level of maintenance and updates as a pre-built library like Lodash. **Library: Lodash** Lodash is a popular JavaScript utility library that provides a comprehensive set of functions for common tasks, such as string manipulation, array processing, and more. The `inRange` function is part of this library and is used in the benchmark to compare its performance with the plain JavaScript implementation. **Special JS Feature/Syntax: None** There are no special JavaScript features or syntaxes mentioned in the provided code snippets.
Related benchmarks:
lodash range vs Array.from vs keys() + spread
Lodash inRange vs JS inRange 2
_.range(N) vs [...Array(N).keys()]
lodash range vs Array.from vs keys() + spread 234das
Comments
Confirm delete:
Do you really want to delete benchmark?