ugexe / Raku-Text--Levenshtein--Damerau

Damerau Levenshtein edit distance in Raku
Artistic License 2.0
6 stars 1 forks source link

Make ld, dld about two times faster #11

Closed titsuki closed 6 years ago

titsuki commented 6 years ago

Use min or max instead of [min] or [max] since the former is faster.

Benchmark:

$ perl6 -e 'use Bench; use Text::Levenshtein::Damerau; my $b = Bench.new; $b.timethis(1000, sub { ld("abcd","vwxy") });'
          : 1.085 wallclock secs (1.108 usr 0.028 sys 1.136 cpu) @ 921.564/s (n=1000)

$ PERL6LIB=lib perl6 -e 'use Bench; use Text::Levenshtein::Damerau; my $b = Bench.new; $b.timethis(1000, sub { ld("abcd","vwxy") });'
          : 0.555 wallclock secs (0.564 usr 0.040 sys 0.604 cpu) @ 1800.199/s (n=1000)

$perl6 -e 'use Bench; use Text::Levenshtein::Damerau; my $b = Bench.new; $b.timethis(1000, sub { dld("abcd","vwxy") });'
          : 1.147 wallclock secs (1.172 usr 0.028 sys 1.200 cpu) @ 871.981/s (n=1000)

$ PERL6LIB=lib perl6 -e 'use Bench; use Text::Levenshtein::Damerau; my $b = Bench.new; $b.timethis(1000, sub { dld("abcd","vwxy") });'
          : 0.583 wallclock secs (0.620 usr 0.004 sys 0.624 cpu) @ 1714.969/s (n=1000)

Version:

$ perl6 --version
This is Rakudo version 2018.02.1-172-g34889bebc built on MoarVM version 2018.02-171-geee5be412
implementing Perl 6.c.
titsuki commented 6 years ago

Thanks for reviewing!