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

Use Enumerable#min instead of defined module function. #1

Closed
wants to merge 1 commit into from

Conversation

fortissimo1997
Copy link
Contributor

I think Enumerable#min is more well-known and useful method than using self defined method.

@yuki24
Copy link
Member

yuki24 commented Sep 26, 2014

Thanks for the request! Actually I'm aware of #min but intentionally left #min3 for performance reasons. In fact, the commit on rubygems/rubygems@a7b2c2d is the exact opposite change of yours. Does it make sense?

@fortissimo1997
Copy link
Contributor Author

Thanks for your reply with detailed reason of current implementation!
I've just measured the performance of each version,
#min3 version is faster!
I'll close this request.

Current version

pry(main)> Benchmark.measure { 10000.times { DidYouMean::Levenshtein.distance("method_missing", "method_mising") } }
=>   0.970000   0.000000   0.970000 (  0.970087)

Enumerable#min version

pry(main)> Benchmark.measure { 10000.times { DidYouMean::Levenshtein.distance("method_missing", "method_mising") } }
=>   1.630000   0.000000   1.630000 (  1.631267)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants