in reply to Challenge: Fast Common Substrings
Okay here is a benchmark as requested. I doubt it will satisfy everyone.
Some comments on the benchmark and results obtained.
To this end I used 'A'..'D', which produces a few at 3, 4, & 5 characters long, but never longer that I saw.
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.
Maybe I screwed up, but I don't think so. It's also the second slowest algorithm.
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Challenge: Fast Common Substrings
by BrowserUk (Patriarch) on Apr 05, 2007 at 15:34 UTC | |
by eric256 (Parson) on Apr 06, 2007 at 20:14 UTC | |
Re^2: Challenge: Fast Common Substrings
by eric256 (Parson) on Apr 06, 2007 at 20:07 UTC |