Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Okay here is a benchmark as requested. I doubt it will satisfy everyone.

Some comments on the benchmark and results obtained.

  1. Randomly generated strings of 30 .. 50 lower case characters rarely if ever produce common substrings of 3 characters, never mind longer.

    To this end I used 'A'..'D', which produces a few at 3, 4, & 5 characters long, but never longer that I saw.

  2. Even adjacent pairings of 5000 strings takes a very long time to run, never mind a full combinatorial pairing.

    I used 500 strings instead. It's a command line parameter, if you've the time and inclination to run 5000, go ahead. I doubt it will make any huge difference to the outcome.

    theZip's (TZ) code is horrible to benchmark as it relies upon a global var. Ie. The sub does not return the result.

    I had a half hearted attempt to address this using a helper sub closing over the global, but the result are wildly inaccurate. Possibly? the fault of my adaption. Sorry thezip.

    However, it seems to be far and away the slowest algorithm anyway.

  3. eric256's (eric) code produces numbers that seem not to relate to the inputs as far a I can discern.

    Maybe I screwed up, but I don't think so. It's also the second slowest algorithm.

  4. Mine (Buk), blokhead's (BH1/BH2), moron's (MN), and Limbic~Region's (LR) code all produce the same counts (although Limbic~Region's has been seen to be one shy of the others on a few occasions).

    The level of concurrence between these disparate algorithms and implementations is taken to indicate that they are producing the correct results. I have not manually verified them.

Results (500 random strings of 'A'..'D', tested each against the next for common substrings 3-7 characters

c:\test>608174-b -N=500 -LENGTH=3 (warning: too few iterations for a reliable count) Rate TZ Eric BH1 MN BH2 L~R Buk TZ 9.06e-002/s -- -98% -98% -99% -99% -99% -100% Eric 4.15/s 4481% -- -19% -41% -63% -75% -85% BH1 5.12/s 5548% 23% -- -27% -55% -70% -82% MN 7.02/s 7642% 69% 37% -- -38% -58% -75% BH2 11.3/s 12354% 172% 121% 61% -- -33% -59% L~R 16.9/s 18532% 307% 230% 141% 50% -- -39% Buk 27.7/s 30457% 567% 441% 295% 145% 64% -- ---- BH2 => 14 L~R => 14 Eric => 31 Buk => 14 BH1 => 14 TZ => 393262 MN => 14 c:\test>608174-b -N=500 -LENGTH=4 (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate TZ Eric BH1 MN L~R BH2 Buk TZ 9.01e-002/s -- -97% -98% -98% -99% -99% -100% Eric 2.87/s 3079% -- -40% -52% -83% -84% -88% BH1 4.78/s 5198% 67% -- -20% -71% -73% -80% MN 6.00/s 6556% 109% 26% -- -64% -65% -75% L~R 16.5/s 18153% 474% 245% 174% -- -5% -33% BH2 17.4/s 19167% 506% 264% 189% 6% -- -29% Buk 24.5/s 27060% 754% 413% 308% 49% 41% -- ---- BH2 => 5 L~R => 5 Eric => 34 Buk => 5 BH1 => 5 TZ => 396184 MN => 5 c:\test>608174-b -N=500 -LENGTH=5 (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate TZ Eric BH1 MN L~R BH2 Buk TZ 9.10e-002/s -- -96% -98% -98% -99% -100% -100% Eric 2.23/s 2352% -- -54% -63% -86% -90% -91% BH1 4.85/s 5227% 117% -- -20% -70% -77% -80% MN 6.06/s 6551% 171% 25% -- -63% -72% -75% L~R 16.4/s 17953% 636% 239% 171% -- -23% -33% BH2 21.3/s 23338% 856% 340% 252% 30% -- -13% Buk 24.5/s 26791% 997% 405% 304% 49% 15% -- ---- BH2 => 1 L~R => 1 Eric => 35 Buk => 1 BH1 => 1 TZ => 387220 MN => 1 c:\test>608174-b -N=500 -LENGTH=6 (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate TZ Eric BH1 MN L~R BH2 Buk TZ 9.04e-002/s -- -95% -98% -99% -99% -100% -100% Eric 1.73/s 1814% -- -65% -72% -90% -92% -93% BH1 4.92/s 5344% 184% -- -20% -70% -79% -81% MN 6.13/s 6687% 255% 25% -- -63% -73% -76% L~R 16.7/s 18321% 862% 238% 171% -- -27% -34% BH2 22.9/s 25257% 1225% 366% 274% 38% -- -9% Buk 25.2/s 27829% 1359% 413% 312% 52% 10% -- ---- BH2 => 0 L~R => 0 Eric => 35 Buk => 0 BH1 => 0 TZ => 391688 MN => 0 c:\test>608174-b -N=500 -LENGTH=7 (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate TZ Eric BH1 MN L~R BH2 Buk TZ 9.08e-002/s -- -94% -98% -99% -99% -100% -100% Eric 1.47/s 1521% -- -70% -76% -91% -94% -94% BH1 4.93/s 5327% 235% -- -21% -71% -80% -81% MN 6.22/s 6748% 322% 26% -- -63% -74% -76% L~R 16.9/s 18554% 1051% 244% 172% -- -30% -33% BH2 24.1/s 26469% 1539% 390% 288% 42% -- -5% Buk 25.4/s 27899% 1627% 416% 309% 50% 5% -- ---- BH2 => 0 L~R => 0 Eric => 32 Buk => 0 BH1 => 0 TZ => 393468 MN => 0

The benchmark code. CLI parameters are: -N=nn numbers of strings to generate; -LENGTH=mm: length of common substrings to look for; Interesting challenge Limbic~Region, thanks.


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.

In reply to Re: Challenge: Fast Common Substrings by BrowserUk
in thread Challenge: Fast Common Substrings by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found