Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Can you write a faster code to perform this task?

by karlgoethebier (Abbot)
on Sep 29, 2014 at 13:32 UTC ( [id://1102356]=note: print w/replies, xml ) Need Help??


in reply to Can you write a faster code to perform this task?

Not the fastest but nice: scalar map { /(M+)/g } ($str);

Compared to the anon monk's benchmark below:

count 3 map 3 regex 3 split 3 Rate split regex map count split 207677/s -- -7% -28% -47% regex 223050/s 7% -- -23% -43% map 288533/s 39% 29% -- -27% count 394162/s 90% 77% 37% --

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found