Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Fast Way to Split String in to Chunk of Equal Length

by davido (Cardinal)
on Nov 25, 2011 at 08:11 UTC ( #939995=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
        @substrings = unpack( '(a3)*', $main::string );
        return \@substrings;
    }
    
  2. or download this
    Benchmark: timing 10000000 iterations of control, match, substr, unpac
    +k...
       control:  5 wallclock secs ( 5.65 usr +  0.00 sys =  5.65 CPU) @ 17
    +69911.50/s (n=10000000)
         match: 22 wallclock secs (21.12 usr +  0.00 sys = 21.12 CPU) @ 47
    +3484.85/s (n=10000000)
        substr: 12 wallclock secs (11.88 usr +  0.00 sys = 11.88 CPU) @ 84
    +1750.84/s (n=10000000)
        unpack:  8 wallclock secs ( 9.04 usr +  0.00 sys =  9.04 CPU) @ 11
    +06194.69/s (n=10000000)
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2020-04-05 22:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (36 votes). Check out past polls.

    Notices?