#! perl -slw use strict; use Time::HiRes qw( gettimeofday tv_interval ); my $re = ''; $re .="(?:(?:(.)(?:\\$_*))|\$)" for 1 .. 500; $re = qr/$re/o; my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qq( ),qw(! @ $ % ^ & *) ); for ( 0 .. 100 ) { my $max_size = int(rand(600)) + 2; my $stn = ""; $stn .= @chars[rand @chars] x int(rand(9)) for 1 .. $max_size; my $iterations = int(rand(600)) + 500; print 'STRING:', $stn; print 'Iterations: ', $iterations; print 'Length: ', length($stn); for my $sub ( qw/Enlil_2 Dingus_1 PhiRatE_2 Rasta_1 TommyW_1 Robartes_1 BrowserUk Dingus_2 Enlil_1/ ){ #! p_process_2/ ) { my $res; my $t0 = [gettimeofday]; for (1..$iterations) { no strict 'refs'; $res = &{$sub}($stn); } printf "%20s: %7.5f sec/iteration found:%3d\n", $sub, tv_interval( $t0 )/$iterations, scalar @$res; } } sub BrowserUk { $_ = shift; my @c = m/$re/; $#c = $#- -1; return \@c; } sub Enlil_1 { $_ = shift; my @bah; my $old_pos = 0; while ( /((.)\2*)/g ) { push @bah, [$2,$old_pos,length($1)]; $old_pos = pos(); } return \@bah; } sub Enlil_2 { $_ = shift; my @bah; while ( /((.)\2*)/g) { push (@bah, [$2,$-[1],$+[1] - $-[1]]); } return \@bah; } sub Dingus_1 { my $string = shift; my ($p, $c, $i, @res) = (0, substr($string,0,1)); for ($i=1; $i