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

Dynamic optimization in levenshtein distance #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Dynamic optimization in levenshtein distance #3

wants to merge 4 commits into from

Conversation

emilianobovetti
Copy link

@emilianobovetti emilianobovetti commented Feb 14, 2018

I tried to write a more efficient implementation for levenshtein distance, forgive me if the code is a bit messy, didn't have time for aesthetics. Anyway benchmarks I ran show appreciable performance benefit:

istantanea_2018-02-14_00-57-35

of course there is still much room for further optimization, but I think it's a starting point!

Since computational complexity is O(n*m) it won't scale well on large strings, I tried on moderately long strings as pointed out in #1 and with following input elm-benchmark gives 92 runs/s on my laptop (i3-6006U).

EditDistance.levenshteinFromStrings
    "abcd111111111100000000001111111111000000000011111111110000000000"
    "111111111100000000001111111111000000000011111111110000000000"

I added fuzz testing just to be sure there aren't uncovered edge cases.

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.

1 participant