After exclusions on functionality, the three left standing -- DamianConway, tobyink & AnomalousMonk -- went forward to performance testing where the latter quickly fell by the wayside.
Of the remaining two, tobyink's solution is hands down winner with a cumulative 66 seconds version DamianConway's 1670 seconds:
...
my @bases = (
'fred',
join( '', 'a'..'z' ),
unpack( 'b*', pack 'Q*', 0 .. 99 ),
);
my %res;
for my $base ( @bases ) {
for my $reps ( 1, 10, 100, 1000 ) {
my $str = $base x $reps . substr( $base, 0, rand( length $base
+ ) );
for my $test ( keys %tests ) {
my $start = time;
my $res;
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm $T * $reps;
$res = $tests{ $test }->( \$str ) // 'none found';
alarm 0;
};
if( $@ eq "timeout\n" ) {
delete $tests{ $test };
warn "$test timed out [@{[ $T * $reps ]}]; excluded\n"
+;
next;
}
my $stop = time;
warn "$test: Found '$res' instead of '$base'\n" unless $re
+s eq $base;
$res{ $test }{ length( $base ) }{ $reps } = $stop - $start
+;
$res{ $test }{ length( $base ) }{ all } += $stop - $start;
$res{ $test }{ all } += $stop - $start;
printf "b:%5u in s:%10u %10s :: %f s\n",
length( $base ), length( $str ), $test, $stop - $start
;
}
}
}
pp \%res;
__END__
[18:23:33.12] C:\test>1039630-b.pl14 -SHOW=0 -T=10
tye found 'fredfrefred'; excluded from further consideration
svc4 found 'redfrefredf'; excluded from further consideration
hdb found 'none found'; excluded from further consideration
choroba found 'fredfrefredfre'; excluded from further consideration
Eily found 'fredfrefred'; excluded from further consideration
Partisipants in performance tests: anomalous tobyink damianc
anomalous timed out [10]; excluded
{
anomalous => {
4 => { 1 => "0.000113964080810547", 10 => "0.000288963317871094
+", 100 => "0.00277900695800781", 1000 => "0.0275580883026123",
all => "0.0307400226593018", },
26 => { 1 => "0.0011751651763916", 10 => "0.00826501846313477",
+100 => "0.118575096130371", 1000 => "4.02753186225891",
all => "4.15554714202881", },
all => "4.18628716468811",
},
damianc => {
4 => { 1 => "0.000234842300415039", 10 => "0.000370979309082031",
+ 100 => "0.000273942947387695", 1000 => "0.000956058502197266",
all => "0.00183582305908203",
},
26 => { 1 => "0.000357866287231445", 10 => "0.000438928604125977"
+, 100 => "0.00239300727844238", 1000 => "0.0216219425201416",
all => "0.0248117446899414",
},
6400 => { 1 => "1.69514513015747", 10 => "12.9105410575867", 100
+=> "135.586049079895", 1000 => "1520.64571499825",
all => "1670.83745026588",
},
all => "1670.86409783363",
},
tobyink => {
4 => { 1 => "0.000294923782348633", 10 => "0.000179052352905273",
+ 100 => "5.60283660888672e-005", 1000 => "5.10215759277344e-005",
all => "0.000581026077270508", },
26 => { 1 => "7.60555267333984e-005", 10 => "0.000123977661132813
+", 100 => "0.00015711784362793", 1000 => "0.000526189804077148",
all => "0.000883340835571289",
},
6400 => { 1 => "0.071134090423584", 10 => "0.232213973999023", 10
+0 => "4.46547484397888", 1000 => "61.8524870872498",
all => "66.6213099956512",
},
all => "66.6227743625641",
},
}
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.