Very low performance of comparison functions
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I'm doing migration from moment.js to dayjs. I have some heavy charts with a lot of comparing dates functionalities. I made a simple benchmark to compare moment and dayjs performance on specific functions.
This is the simple function i was using to test it I just changed the methods inside.
```
const benchmark = () => {
console.time("dayjs");
const date1 = dayjs("2018-04-13 19:18");
const date2 = dayjs("2020-04-13 19:18");
for (let i = 0; i < 10000; i++) {
date1.isSameOrBefore(date2);
date1.isSameOrAfter(date2);
}
console.timeEnd("dayjs");
console.time("moment");
const date3 = moment("2018-04-13 19:18");
const date4 = moment("2020-04-13 19:18");
for (let i = 0; i < 10000; i++) {
date3.isSameOrBefore(date4);
date3.isSameOrAfter(date4);
}
console.timeEnd("moment");
};
```
.isSameOrBefore() / .isSameOrAfter()
  
.startOf('month) / .endOf('month)
  
.isBefore() / .isAfter()

.isSame()

.isBetween()

I hope u guys gonna help me maybe I'm doing something wrong with these functions.
As you can see these differences have huge impact on my usage of this library.
My dayjs with plugins instance (I checked without plugins (isBefore,isAfter,isSame) and it has the same results
```
// Load dayjs, plugins and language packs.
import dayjs from 'dayjs';
import timeZonePlugin from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import duration from 'dayjs/plugin/duration';
import isBetween from 'dayjs/plugin/isBetween';
import isoWeek from 'dayjs/plugin/isoWeek';
// Register plugins and language packs;.
dayjs.extend(timeZonePlugin);
dayjs.extend(utc);
dayjs.extend(customParseFormat);
dayjs.extend(isSameOrBefore);
dayjs.extend(isSameOrAfter);
dayjs.extend(duration);
dayjs.extend(isBetween);
dayjs.extend(isoWeek);
export default dayjs;
```
**Information**
- "moment": "2.29.3", "dayjs": "1.11.8",
- Win 11
- Chrome newest
- Time zone: GMT+2
Contributor guide
Assessment
This issue has not been assessed yet.