use strict; use warnings; use Time::HiRes 'time'; use Readonly; Readonly my $SIZE => 10_000_000; my $str; { # get us some data use String::Random 'random_regex'; srand 1234; $str = random_regex( "[ACTG]{$SIZE}" ); } { print "\nlet's test PDL!\n"; use PDL; my $t = time; my $p = PDL-> new_from_specification( byte, $SIZE ); ${ $p-> get_dataref } = $str; $p-> upd_data; my ( $lengths, $values ) = $p-> rle; my $cumu = $lengths-> cumusumover; my $C_lengths = $lengths * ( $values == ord 'C' ); my ( undef, $max, undef, $max_ind ) = $C_lengths-> minmaximum; report( $max, $cumu-> at( $max_ind - 1 ), time - $t ) } { print "\nlet's test pure Perl's re-engine!\n"; my $t = time; my $best = [ -1, -1 ]; while ( $str =~ /((C)\2+)/g ) { $best = [ length( $1 ), $-[ 1 ]] if length $1 > $best-> [ 0 ] } report( @$best, time - $t ) } sub report { printf "\tmax run of C's is %d bases long at %d\n\ttime consumed: %f\n", @_ } __END__ let's test PDL! max run of C's is 11 bases long at 4367281 time consumed: 0.164513 let's test pure Perl's re-engine! max run of C's is 11 bases long at 4367281 time consumed: 0.361907