Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I'm not sure why you have the regex engine check if each character is not a newline in isook. Use the "s" modifier!

Interesting about pack. I heard the overhead to start the regex engine went up in 5.10, but it seems rather minor when put into perspective. ...except I can't replicate your results.

use strict; use warnings; use Benchmark qw(:all); print("This is Perl $]\n"); my %tests = ( repeat => 'my ($y,$m,$d) = $date =~ /(\\d\\d\\d\\d)(\\d\\d)(\\d\\d +)/;', range => 'my ($y,$m,$d) = $date =~ /(\\d{4})(\\d{2})(\\d{2})/;', isook => 'my ($y,$m,$d) = $date =~ /(....)(..)(..)/s;', unpack => 'my ($y,$m,$d) = unpack "A4 A2 A2", $date;', ); # These don't result in any opcodes. $_ = 'use strict; use warnings; our $date; '.$_ for values(%tests); our $date = '20091202'; my $results = cmpthese(-3, \%tests);
This is Perl 5.010000 Rate range repeat isook unpack range 405773/s -- -6% -8% -46% repeat 432956/s 7% -- -2% -43% isook 441233/s 9% 2% -- -42% unpack 757010/s 87% 75% 72% -- This is Perl 5.010000 Rate range isook repeat unpack range 398141/s -- -7% -7% -47% isook 427913/s 7% -- -0% -43% repeat 429311/s 8% 0% -- -43% unpack 751802/s 89% 76% 75% -- This is Perl 5.010000 Rate range repeat isook unpack range 415595/s -- -7% -8% -45% repeat 445365/s 7% -- -1% -41% isook 449974/s 8% 1% -- -40% unpack 754290/s 81% 69% 68% --

The faster way seems to be using the capture made of dots as in "isook"

You haven't shown that. Any difference less than 5% should be ignored. It's within the error margin.

In reply to Re^3: better (faster) way of writing regexp by ikegami
in thread better (faster) way of writing regexp by jodaka

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (7)
    As of 2014-08-23 10:41 GMT
    Find Nodes?
      Voting Booth?

      The best computer themed movie is:

      Results (173 votes), past polls