Hi,
I added another version, that split string that split with a smaller last chunk. Added also a /o, to improve performace (that can be used if you have several lines to split.
Added this to the benchmark:
'regex' => sub
{
my @arr = $string =~ /(........)/g;
},
'regexo' => sub
{
my @arr = $string =~ /(.{1,8})/og;
},
The results:
Rate split_pos split grep_split substr_map substr_lo
+op unpack regex regexo
split_pos 7295/s -- -57% -60% -68% -7
+7% -78% -100% -100%
split 16900/s 132% -- -7% -26% -4
+7% -50% -100% -100%
grep_split 18241/s 150% 8% -- -20% -4
+3% -46% -100% -100%
substr_map 22883/s 214% 35% 25% -- -2
+9% -32% -99% -100%
substr_loop 32139/s 341% 90% 76% 40%
+-- -4% -99% -99%
unpack 33495/s 359% 98% 84% 46%
+4% -- -99% -99%
regex 4342185/s 59421% 25593% 23705% 18876% 1341
+1% 12864% -- -6%
regexo 4596612/s 62909% 27098% 25099% 19988% 1420
+2% 13623% 6% --
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.