Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
moment date sort 2
(version: 0)
Comparing performance of:
no memoization vs with memoization vs with memoization (integer) vs no memoization (integer)
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.0/moment.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var _sortMomentDates = (a, b) => { if (a.isSame(b)) { return 0; } return a.isBefore(b) ? -1 : 1; }; var _sortDateValues = (a, b) => b - a; var sortMomentDates = _.memoize(_sortMomentDates, (...args) => args.map(v => v.format('MM/DD/YYYY')).join("_")); var sortDateValues = _.memoize(_sortDateValues, (a, b) => BigInt(a) << 17n | BigInt(b)); var rawDates = [{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"},{"startDate":"2020-06-01","endDate":"2020-06-30"},{"startDate":"2020-07-01","endDate":"2020-07-31"},{"startDate":"2020-08-01","endDate":"2020-08-31"},{"startDate":"2020-09-01","endDate":"2020-09-30"},{"startDate":"2020-10-01","endDate":"2020-10-31"},{"startDate":"2020-11-01","endDate":"2020-11-30"},{"startDate":"2020-12-01","endDate":"2020-12-31"},{"startDate":"2020-02-01","endDate":"2020-02-29"},{"startDate":"2020-03-01","endDate":"2020-03-31"},{"startDate":"2020-04-01","endDate":"2020-04-30"},{"startDate":"2020-05-01","endDate":"2020-05-31"}]; var momentDates = rawDates.map(e => moment(e.startDate)); var dateValues = momentDates.map(x => 10000 * x.year() + 100 * x.month() + x.date());
Tests:
no memoization
var sortedDates = momentDates.sort(_sortMomentDates);
with memoization
var sortedDates = momentDates.sort(sortMomentDates);
with memoization (integer)
var sortedDates = dateValues.sort(sortDateValues);
no memoization (integer)
var sortedDates = dateValues.sort(_sortDateValues);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
no memoization
with memoization
with memoization (integer)
no memoization (integer)
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):
I'll do my best to analyze the provided data and provide an answer. **Benchmark Results Analysis** The latest benchmark results show variations in execution speed for different test cases: 1. **No Memoization (Integer)**: Chrome 80 on Windows, desktop platform, with an execution speed of 506,111.25 executions per second. 2. **No Memoization**: Same as above, but without specifying the device platform or operating system, with an execution speed of 195,710.84 executions per second. 3. **With Memoization (Integer)**: Chrome 80 on Windows, desktop platform, with an execution speed of 16,031.83 executions per second. 4. **With Memoization**: Same as above, but without specifying the device platform or operating system, with an execution speed of 5,549.17 executions per second. **Observations** * The "no memoization" test cases show significant variations in execution speed (up to 2.6x difference), suggesting that memoization has a substantial impact on performance. * The "with memoization" test cases exhibit relatively stable execution speeds, indicating that memoization leads to consistent and efficient performance. * The lack of specific device platform or operating system information for some benchmark results makes it challenging to draw conclusions about the impact of these factors on performance. **Question** Based on these benchmark results, can you infer anything about the optimization techniques used in the code (e.g., whether memoization is effective)?
Related benchmarks:
Date sort
moment date sort
Lodash min vs sort moment (lodash 4.7.11)
Array.prototype.sort (utc date property vs epoch date simulation property)
Comments
Confirm delete:
Do you really want to delete benchmark?