Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: 4x faster now!

by h2 (Beadle)
on Jul 19, 2018 at 20:37 UTC ( [id://1218849]=note: print w/replies, xml ) Need Help??


in reply to Re: 4x faster now!
in thread Syntax Perl Version support $c = () = $a =~ /\./g

I was lucky and discovered NTYProf quite early, so along with loop testing, I was able to get rid of major bottlenecks during development, which was and is kind of excellent. There's some optimization tricks I was not aware of in that perlperf page so those should help too, I've been using microtimers in loops which achieve the same result but I'll check out some of the other optimization tools, thanks. As noted above, sadly, the improvements once I made both test versions fully apples to apples turned out to be roughly 'only' 2.5x faster for tr and length vs regex. But equally obviously, anything that results in that big of a difference is worth understanding better, since usually you hope for 5, 10% improvements, not 250%.

Replies are listed 'Best First'.
Re^3: 4x faster now!
by kcott (Archbishop) on Jul 20, 2018 at 10:07 UTC
    "... roughly 'only' 2.5x faster ..."

    Interestingly, if you look at the benchmark timings in the perlperf page:

    $ perl -E 'say 2040816.33/840336.13' 2.42857144557143

    But don't read too much into that: I consider it more of a curiosity than anything else.

    "... anything that results in that big of a difference is worth understanding better ..."

    Someone else may have a much better answer regarding the inner workings of these. My understanding is that the SEARCH part of y///, e.g. the 'w' in

    $ perl -E 'say "xwz" =~ y/w/y/r' xyz

    is handled at compile time; whereas the equivalent part of s///, e.g. the 'w' in

    $ perl -E 'say "xwz" =~ s/w/y/r' xyz

    is handled at runtime. I couldn't tell you exactly what "handled" equates to; maybe another monk can chime in with a more complete answer.

    — Ken

Log In?
Username:
Password:

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

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

    No recent polls found