Skip to content

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