-
-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improved performance speed for getOrderOfEvent and getCountOfEventsAtEvent methods #1124
fix: improved performance speed for getOrderOfEvent and getCountOfEventsAtEvent methods #1124
Conversation
…ntsAtEvent methods
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@arisyo13 is attempting to deploy a commit to the Kazuya Gosho's projects Team on Vercel. A member of the Team first needs to authorize it. |
expect(index).toEqual(2) | ||
}) | ||
|
||
test('3 events end', () => { | ||
const event = events[5] | ||
const index = utils.getOrderOfEvent(event, events) | ||
expect(index).toEqual(2) | ||
expect(index).toEqual(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw as you can see i have adjusted the tests here to satisfy new changes.
Although as you will correctly assume that the changes that i did possibly broke the functionality.
To be able to understand why, I took the mocked events from tests and used them in rndemo project.
This way i am able to visualise them in the screenshots below. (i adjusted year from 2021 to 2024 so i don't have to scroll forever to get there)
As we can see we have three overlapping events which need to be sorted based on chronological order.
Let's analyse the events from testEvents:
"Repair my car" (2024-09-18T05:45 to 2024-09-18T11:30)
"Meet Realtor" (2024-09-18T06:25 to 2024-09-18T07:55)
"Laundry" (2024-09-18T06:25 to 2024-09-18T09:00)
These three events overlap with each other.
Sorting them in order of start time:
"Repair my car" (Start: 05:45, End: 11:30)
"Meet Realtor" (Start: 06:25, End: 07:55)
"Laundry" (Start: 06:25, End: 09:00)
Thus, the sorted order of overlapping events is:
Repair my car (2024-09-18T05:45 to 2024-09-18T11:30)
Meet Realtor (2024-09-18T06:25 to 2024-09-18T07:55)
Laundry (2024-09-18T06:25 to 2024-09-18T09:00)
Default Sorting Criteria for Overlapping Events:
Primary Criterion: Start Time
Events are primarily sorted by their start time (earlier start time comes first).
Secondary Criterion: End Time (Tie-Breaker)
When two events have the same start time, the event with the earlier end time takes precedence. This ensures shorter events come first.
Applying this to "Meet Realtor" and "Laundry":
Start Times: Both start at 06:25, so we move to the secondary criterion.
End Times:
"Meet Realtor" ends at 07:55.
"Laundry" ends at 09:00.
Since "Meet Realtor" ends earlier, it is sorted first.
@arisyo13 Thank you very much for the PR! The binary search and early break is genious. Checked the storybook and working fine. Let me merge this! |
Released on v4.16.1 |
I used rndemo project in order to understand why modes of
week
day
and3days
where very slow when trying to navigate them.To be able to render 87 events on
week
mode it was taking approx 1260msI applied to stress it even further with 500 events which took a bit over a minute 62seconds.
Of course this makes the library almost unusable since in all real life scenarios we will navigate from a screen to this one and that could take some time to render.
After i applied the proposed fixes