Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
New Lodash sortBy vs orderBy fixed
(version: 0)
Lodash sortBy vs orderBy
Comparing performance of:
_.sortBy vs _.orderBy
Created:
3 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:
function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } var arr = []; for(var i = 0; i < 100000; i++){ arr.push({value:getRandomInt(100)}); }
Tests:
_.sortBy
_.sortBy(arr,"value");
_.orderBy
_.orderBy(arr,"value");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.sortBy
_.orderBy
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.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what is being tested in this JavaScript microbenchmark. **Benchmark Definition** The benchmark is comparing two functions from the Lodash library: `_.sortBy` and `_.orderBy`. Both functions are used to sort an array of objects based on a specific value. **Options Compared** The two options being compared are: 1. **_.sortBy**: This function sorts the array in ascending order by default, using the specified value as the sorting criteria. 2. **_.orderBy**: This function also sorts the array, but with an option to specify the sort direction (ascending or descending). By default, it's set to ascending. **Pros and Cons of Each Approach** * **_.sortBy**: + Pros: Simple, fast, and efficient for small datasets. + Cons: May not be suitable for larger datasets where sorting performance is critical. * **_.orderBy**: + Pros: Allows for more flexibility in terms of sort direction, which can be beneficial for certain use cases. + Cons: May introduce additional overhead due to the extra option and logic. **Library - Lodash** Lodash (formerly known as Underscore.js) is a popular JavaScript utility library that provides various functions for tasks like array manipulation, object creation, and more. In this benchmark, we're using two of its sorting functions, `_.sortBy` and `_.orderBy`, to compare their performance. **Other Considerations** The benchmark also includes some additional considerations: * The script preparation code generates an array of 100,000 objects with random values. * The HTML preparation code includes the Lodash library from a CDN. * The test cases are run on Chrome 108, with the device platform set to Desktop and the operating system set to Mac OS X 10.15.7. **Special JS Feature - ES6** There is no explicit mention of any special JavaScript features or syntax in this benchmark. However, it's worth noting that Lodash uses modern JavaScript features like async/await and Promises, which are part of ES6+ standards. **Alternative Benchmarks** If you're interested in exploring alternative benchmarks for sorting arrays in JavaScript, here are a few options: * Google's Benchmark: A widely used benchmarking tool for JavaScript. * JSPerf: A popular online platform for running JavaScript performance comparisons. * Micro-ORM benchmarks (e.g., Lodash, Moment.js): These benchmarks compare the performance of various libraries and frameworks.
Related benchmarks:
Lodash orderBy() vs array.prototype.sort
lodash sortBy vs native sortBy 4.17.21
Lodash sortBy vs orderBy performance
Lodash orderBy vs array.prototype.sort fork
Lodash orderBy (fn) vs array.prototype.sort small array
Comments
Confirm delete:
Do you really want to delete benchmark?