in reply to A better implementation of LCSS?
|
|---|
| Replies are listed 'Best First'. | |||||||
|---|---|---|---|---|---|---|---|
|
Re^2: A better implementation of LCSS?
by BrowserUk (Patriarch) on Jan 28, 2010 at 02:59 UTC | |||||||
I thought about that, but in the normal way of things *::PP modules are fallbacks for when the *::XS version won't compile. A reliable but slow option. In this case, it is actually faster. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] | ||||||
by ikegami (Patriarch) on Jan 28, 2010 at 03:48 UTC | |||||||
I agree. For this module, it not relevant that it's written in Perl. Longest common subsequence is also abbreviated LCS, and String::LCS is not currently used. Update: And of course, that's not the problem you are solving. It does go to show that LCSS is a bad choice anyway.
String::LCSubstr? | [reply] | ||||||
by BrowserUk (Patriarch) on Jan 28, 2010 at 06:52 UTC | |||||||
String::LCSubstr? I'm coming to the conclusion, that is the least-worst option. Now all I got do is remember my PAUSE credentials and how to package it up. | [reply] | ||||||
by lima1 (Curate) on Jan 28, 2010 at 16:31 UTC | |||||||
| [reply] | ||||||
by BrowserUk (Patriarch) on Jan 28, 2010 at 23:50 UTC | |||||||
Good question! In the benchmark cited, I used 100 1000-char string (just because that was what the benchmark of another algorithm posted here used). In the following examples, LCSS10.pl is the script that uses String::LCSS_XS. The -MIN= parameter to the script simply stops it printing out any results less than MIN length. It doesn't stop it looking for and finding them. LCSSN.pl uses my pp implementation. Here, the -MIN= parameter doesn't stop it locating smaller matches. But it does stop it from considering them when looking for the best match, which helps performance a lot. Increasing the length doesn't affect the performance differential much. If anything it seems to favour my implementation. The following is run on 4, 100,000 char strings:
However, reducing the -MIN=2 does affect it, and shows String::LCSS_XS in a good light. The following are run on the same file:
All the extra locating and overwriting the best yet does affect the algorithm badly by comparison. Presumably, if you added a MIN parameter to your code, it would benefit from it when used and would then beat mine blow for blow. That said. Mine works best when there is large length differential between the two strings being compared. It currently makes 2 passes of the longer string for each character in the shorter string. As both are the same length in these benchmarks these tests are worst case. I have a notion that, if coded in C, I can reduce that to 1 pass which would redress the balance a little, but probably not enough to make it worth while for the cases where both strings are approximately the same length. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] | ||||||
by lima1 (Curate) on Jan 29, 2010 at 10:14 UTC | |||||||