Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

SUBSTR OR REGEX: WHICH WILL YOU FAVOUR?

by Anonymous Monk
on Oct 19, 2013 at 19:38 UTC ( [id://1058941]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ...
            $str .= $1 . $/ while ( $ARGV[0] =~ m/(.{3})/g );
    ...
    
  2. or download this
    ...
    use constant LEN => 3;
    ...
                $offset += $length;
            }
    ...
    
  3. or download this
    #!usr/bin/perl -w
    use strict;
    ...
    );
    
    cmpthese($re);
    
  4. or download this
    Benchmark: running regex, substring for at least 2 CPU seconds...
         regex:  1 wallclock secs ( 2.09 usr +  0.00 sys =  2.09 CPU) @ 14
    +030.14/s (n=29323)
    ...
                 Rate     regex substring
    regex     14030/s        --      -40%
    substring 23226/s       66%        --
    
  5. or download this
    ...
            $str .= $1 . $/ while ( $ARGV[0] =~ m/(.{3})/g ); ## NOTE the 
    +number 3
    ...
    
  6. or download this
    ...
            $str .= $1 . $/ while ( $ARGV[0] =~ m/(.{LEN})/g ); ## NOTE 3 
    +is now LEN
    ...
    
  7. or download this
    Benchmark: running regex, substring for at least 2 CPU seconds...
         regex:  4 wallclock secs ( 2.72 usr +  0.01 sys =  2.73 CPU) @ 74
    +0317.95/s (n=2021068)
    ...
                  Rate substring     regex
    substring  17333/s        --      -98%
    regex     740318/s     4171%        --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1058941]
Approved by Athanasius
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-18 10:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found