Skip to content
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

perf(difference): Optimize difference #27

Merged
merged 1 commit into from
Jun 8, 2024
Merged

Conversation

po4tion
Copy link
Contributor

@po4tion po4tion commented Jun 7, 2024

The es-toolkit's difference function becomes slower compared to lodash's difference as the array size increases.
Therefore, I have modified the difference function in es-toolkit so that it performs faster even as the array size increases.

I have reduced the time complexity from O(n*m) to O(n+m).

AS-IS benchmark(es-toolkit vs lodash)

firstArr's size : 10
secondArr's size : 5
image

firstArr's size : 500
secondArr's size : 250
image

TO-BE benchmark(es-toolkit vs lodash)

firstArr's size : 10
secondArr's size : 5
image

firstArr's size : 500
secondArr's size : 250
image

Benchmark(old difference vs new difference)

firstArr's size : 10
secondArr's size : 5
image

firstArr's size : 500
secondArr's size : 250
image

firstArr's size : 10,000
secondArr's size : 5,000
image

Copy link

vercel bot commented Jun 7, 2024

@po4tion is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@po4tion po4tion changed the title fix(difference): Make "difference" fast fix(difference): Make difference fast Jun 7, 2024
@raon0211 raon0211 changed the title fix(difference): Make difference fast perf(difference): Optimize difference Jun 8, 2024
@raon0211 raon0211 changed the title perf(difference): Optimize difference perf(difference): Optimize difference Jun 8, 2024
Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your great contribution!

@raon0211 raon0211 merged commit 4ec747e into toss:main Jun 8, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants