Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: improved levenshtein

by kvale (Monsignor)
on Mar 03, 2004 at 17:59 UTC ( #333633=note: print w/replies, xml ) Need Help??


in reply to improved levenshtein

That is a nice speedup of the pure Perl version of the algorithm.

But if I were you, I would benchmark your code against the XS code before you call your stuff 'fast'. The XS version was written explicitly for speed.

How about submitting a patch for the Text::Levenshtein instead? That way CPAN has one optimized pure Perl module and one optimized XS module for the task, simple.

-Mark

Replies are listed 'Best First'.
Re: Re: improved levenshtein
by bageler (Hermit) on Mar 03, 2004 at 18:36 UTC
    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% --

      The author of both modules is known here as dree, send your patch to him.

      Ciao, Valerio

      does rolling out _min inline make much difference?


      -Waswas
      in the parlance of our times.

      "New shit has come to light, man!"

      Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://333633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2018-10-20 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (117 votes). Check out past polls.

    Notices?