Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Vowel search

by Jim (Curate)
on Jun 11, 2014 at 23:13 UTC ( [id://1089620]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Vowel search
in thread Vowel search

Of course, another approach would be to common-case all lines before matching...

Adding this other approach to your benchmark test…

C:\>type 634253.pl #!perl use strict; use warnings; use Benchmark qw( cmpthese ); use English qw( -no_match_vars ); local $OUTPUT_RECORD_SEPARATOR = "\n"; print 'Perl version: ', $PERL_VERSION; my $s = 'Aid bears out ' x 10_000_000; print 'Length of string: ', length $s; cmpthese(-1, { 'lc' => sub { lc($s) =~ m{ [aeiou][aeiou] }xmsg }, '[Aa][Aa]' => sub { $s =~ m{ [AaEeIiOoUu][AaEeIiOoUu] }xmsg }, '[Aa]{2}' => sub { $s =~ m{ [AaEeIiOoUu]{2} }xmsg }, '/i' => sub { $s =~ m{ (?i) [aeiou]{2} }xmsg }, }); exit 0; C:\>perl 634253.pl Perl version: v5.16.2 Length of string: 140000000 Rate lc [Aa][Aa] /i [Aa]{2} lc 5.20/s -- -100% -100% -100% [Aa][Aa] 2915419/s 56073120% -- -23% -25% /i 3764119/s 72396452% 29% -- -3% [Aa]{2} 3877869/s 74584244% 33% 3% -- C:\>perl 634253.pl Perl version: v5.16.2 Length of string: 140000000 Rate lc [Aa]{2} /i [Aa][Aa] lc 4.94/s -- -100% -100% -100% [Aa]{2} 2814401/s 57019656% -- -8% -25% /i 3044909/s 61689750% 8% -- -19% [Aa][Aa] 3762832/s 76234868% 34% 24% -- C:\>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1089620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found