Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
luxon vs datefns vs moment vs dayjs (calculations) new
(version: 0)
Comparing performance of:
datefns vs luxon vs moment vs dayjs
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.7/dayjs.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/luxon/3.3.0/luxon.min.js"crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js" referrerpolicy="no-referrer"></script>
Script Preparation code:
window.__date__ = new Date(); window.__luxon__ = luxon.DateTime.fromJSDate(__date__); window.__moment__ = moment(__date__); window.__dayjs__ = dayjs(__date__);
Tests:
datefns
dateFns.addYears(__date__, 2);
luxon
__luxon__.plus({ years: 2 });
moment
__moment__.add(2, 'year');
dayjs
__dayjs__.add(2, "year");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
datefns
luxon
moment
dayjs
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser/OS:
Firefox 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
datefns
593213.9 Ops/sec
luxon
194410.3 Ops/sec
moment
1281318.1 Ops/sec
dayjs
198624.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring JavaScript performance is a crucial task in developing robust and efficient applications. Let's break down the provided JSON data: **Benchmark Definition** The benchmark tests the calculation performance of four date manipulation libraries: Luxon, Date-fns, Moment.js, and Day.js. Each library has its own approach to performing calculations on dates. **Options Compared** Here are the options compared in each test case: 1. `dateFns.addYears(__date__, 2)` * This option uses the `addYears` function from Date-fns, which adds a specified number of years to a date. * Pros: Simple and intuitive API, well-documented. * Cons: May not be optimized for performance, relies on browser support for dates. 2. `__luxon__.plus({ years: 2 })` * This option uses the `plus` function from Luxon, which adds a specified amount to a date. * Pros: Optimized for performance, takes into account different time zones and calendar systems. * Cons: More complex API compared to Date-fns, requires manual handling of dates. 3. `__moment__.add(2, 'year');` * This option uses the `add` function from Moment.js, which adds a specified amount of time to a date. * Pros: Wide support for different time units (years, months, days), well-documented. * Cons: May be slower than Luxon or Date-fns due to its parsing overhead. 4. `__dayjs__.add(2, "year");` * This option uses the `add` function from Day.js, which adds a specified amount of time to a date. * Pros: Simple and intuitive API, well-documented. * Cons: May not be optimized for performance, relies on browser support for dates. **Libraries** Here's a brief overview of each library: 1. **Luxon**: A modern JavaScript date library that aims to provide an optimal balance between performance, ease of use, and flexibility. 2. **Date-fns**: A lightweight and easy-to-use date manipulation library with a simple API and good browser support. 3. **Moment.js**: A widely-used date library that provides a wide range of features for manipulating dates, but may have slower performance compared to Luxon or Date-fns. 4. **Day.js**: A modern JavaScript date library that provides an easy-to-use API and good browser support. **Special JS Features/Syntax** None are mentioned in the provided data, so I won't elaborate on any special features or syntax. **Benchmark Preparation Code** The benchmark preparation code sets up each library by creating a new instance of each and storing it in global variables (`window.__date__`, `window.__luxon__`, etc.). This allows each test case to access these libraries directly. **Latest Benchmark Results** The results show the executions per second for each browser and device platform. The test that performed best was Moment.js, followed closely by Luxon. **Other Alternatives** If you're interested in exploring other date manipulation libraries, here are a few alternatives: * **js-joda**: A modern JavaScript implementation of Joda Time, providing a robust set of features for date and time calculations. * **dateutil**: A lightweight JavaScript library that provides date and time utilities, including parsing and formatting dates. * **dayjs-pickr**: A popular alternative to Day.js, providing an easy-to-use API and good browser support. These alternatives may offer different trade-offs in terms of performance, ease of use, or feature set. It's essential to evaluate their suitability for your specific project requirements.
Related benchmarks:
luxon vs datefns vs moment vs dayjs (formatting)
luxon vs datefns vs moment vs dayjs (calculations)
Moment vs Luxon getOffset
luxon 3.2.1 vs datefns vs moment vs dayjs (formatting)
Comments
Confirm delete:
Do you really want to delete benchmark?