Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: You don't always have to use regexes

by kvale (Monsignor)
on Feb 23, 2005 at 16:32 UTC ( [id://433747]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Benchmark qw(:all) ;
    
    ...
                      'eq'    => sub { lc $value eq "true" },
                      'index' => sub { index( lc $value, "true" ) >= 0 },
                     });
    
  2. or download this
    Benchmark: timing 1000000 iterations of eq, index, regex...
            eq:  1 wallclock secs ( 0.89 usr +  0.00 sys =  0.89 CPU) @ 11
    +23595.51/s (n=1000000)
    ...
    index  606061/s    --   -1%  -46%
    regex  613497/s    1%    --  -45%
    eq    1123596/s   85%   83%    --
    
  3. or download this
                      'regex' => sub { $value =~ /true/i },
                      'regex_anch' => sub { $value =~ /^true$/i },
                      'eq'    => sub { lc $value eq "true" },
                      'index' => sub { index( lc $value, "true" ) >= 0 },
    
  4. or download this
    Benchmark: timing 1000000 iterations of eq, index, regex, regex_anch..
    +.
            eq:  1 wallclock secs ( 0.88 usr +  0.00 sys =  0.88 CPU) @ 11
    +36363.64/s (n=1000000)
    ...
    regex_anch  628931/s         4%         --       -32%       -45%
    regex       925926/s        53%        47%         --       -19%
    eq         1136364/s        87%        81%        23%         --
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-03-29 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found