I did also benchmark against the XS module, and my module is quite slow in comparison (duh) unless the strings are equal, where my short circuit (return 0 if $word1 eq $word2) lays the smack down, in the parlance of our times.
for your information, here are my benchmark results:
joshs-Computer:~/leven josh$ perl levenshtein.pl foo fee
The distance between foo and fee is 2
Rate cpan mine cpanxs
cpan 80.6/s -- -16% -97%
mine 95.5/s 18% -- -97%
cpanxs 2844/s 3430% 2879% --
joshs-Computer:~/leven josh$ perl levenshtein.pl foo foo
The distance between foo and foo is 0
Rate cpan cpanxs mine
cpan 83.2/s -- -97% -98%
cpanxs 2849/s 3325% -- -31%
mine 4109/s 4840% 44% --
joshs-Computer:~/leven josh$ perl levenshtein.pl foo bar
The distance between foo and bar is 3
Rate cpan mine cpanxs
cpan 81.2/s -- -15% -97%
mine 95.4/s 18% -- -97%
cpanxs 2829/s 3385% 2865% --
oshs-Computer:~/leven josh$ perl levenshtein.pl 1234567890 0987654321
The distance between 1234567890 and 0987654321 is 10
Rate cpan mine cpanxs
cpan 9.35/s -- -24% -99%
mine 12.3/s 31% -- -99%
cpanxs 1782/s 18966% 14410% --
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|