in reply to Re^2: An efficient way to gather a common portion of several strings' beginnings
in thread An efficient way to gather a common portion of several strings' beginnings

> Update. Some benchmarking ...

your version is of course faster

DB<129> push @a, join "",a..z,rand(1) for 1..1e6 => "" DB<130> $start=time;print lcp_v4(@a);time -$start => 1.25800704956055 abcdefghijklmnopqrstuvwxyz DB<131> $start=time;print lcp_v5(@a);time -$start => 6.93630909919739 abcdefghijklmnopqrstuvwxyz

> # however, these assume strings don't end with \0

See thats the benefit of a simple algorithm, sort doesn't care about \0, one could easily replace the comparison of 2 lines with something stable without notable impact.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^3: An efficient way to gather a common portion of several strings' beginnings
  • Download Code