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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
$cn =~ /^(0|5|6)0+\Q$bn\E$
You never know with demerphq's future optimizations in regexp speed, but I'm quite sure that for now,
/^[056]0+/
will be faster than
/^(?:0|5|6)0+/

Benchmark code:

use Benchmark 'cmpthese'; my @list = ( '00012345', 'D123470', '0000123450', '0000023456', '50000 +123990' ); cmpthese -3, { charclass => sub { grep /^[056]0+/, @list }, alt => sub { grep /^(?:0|5|6)0+/, @list }, };

Benchmark result:

Benchmark: running alt, charclass, each for at least 3 CPU seconds... alt: 3 wallclock secs ( 3.00 usr + 0.00 sys = 3.00 CPU) @ 50 +5561.00/s (n=1516683) charclass: 3 wallclock secs ( 3.20 usr + 0.00 sys = 3.20 CPU) @ 53 +4972.53/s (n=1713517) Rate alt charclass alt 505561/s -- -5% charclass 534973/s 6% --

So it is indeed 5-6% faster, depending how you look at it.


In reply to Re: Merged list with regex matches by bart
in thread Merged list with regex matches by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found