in reply to Re: Fast Way to Split String in to Chunk of Equal Length
in thread Fast Way to Split String in to Chunk of Equal Length
unpack is the way to go, but one tip is that unpack 'a3' x $n, $str runs a few percent quicker than unpack '(a3)*', $str if you know in advance how many fields there are.
How can you not know in advance how many fields there are (int(length($seq)/3))?
avoiding the allocation, creation and destruction of 10 million concurrent small arrays -- even if you have ample memory for them -- can save a significant amounts of time
Any implementation in mind? Something like the following?
while ($seq =~ /(.{3})/sg) { # Substring in $1 ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Fast Way to Split String in to Chunk of Equal Length
by BrowserUk (Patriarch) on Nov 25, 2011 at 17:20 UTC | |
|
Re^3: Fast Way to Split String in to Chunk of Equal Length
by BrowserUk (Patriarch) on Nov 25, 2011 at 20:23 UTC |