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

Re^4: Impact of special variables on regex match performance

by roubi (Hermit)
on Dec 10, 2010 at 00:53 UTC ( [id://876357]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Impact of special variables on regex match performance
in thread Impact of special variables on regex match performance

Concerning your code: given that sub uncomment_one is never explicitly called in what you posted, you may have over-reached in your diligence to follow the guidance ( not exactly "rules ) of this forum.
I put that code in a sub on purpose. The performance impact is triggered by the mere presence of those variables in the code, not their actual use as part of the execution of the script. And so there is no need to imagine a situation where those variables would be actually needed, only one where you'd need to load a module that contains those variables in a sub your code doesn't actually call.
  • Comment on Re^4: Impact of special variables on regex match performance

Replies are listed 'Best First'.
Re^5: Impact of special variables on regex match performance
by ww (Archbishop) on Dec 10, 2010 at 03:21 UTC

    Just a couple nodes back you asserted that NOT using the vars "isn't an option;" Then you conceed that you "didn't mean to say that there are no technical alternatives" Now you're offering justification by way of a hypothetical case in which one might "load a module that contains those variables."

    1. That suggests you'd better take a look at what's in the module that you might load (and, IMO, any module that uses those needs to be scrutinized very carefully for {other} sub-optimal techniques).
    2. Some -- very possibly most -- of the "performance impact is triggered by the mere presence of those variables" but you haven't allocated any of it to the difference between calling a no-op sub (all commented) and a sub with as much as a single operation (one, uncommented). Again, profile it.
    3. You are correct, of course, that some..most of the impact is from declaration, but, as noted by numerous respondents, that's well documented. Learning facts like that is part of the reason for reading the docs.

    UPDATE: Inserted dropped negation, para 1, sentence 1.

      Yes, having those variables not seen at compile time isn't an option, for the reason I already gave. My code is but one piece of a bigger project for which I have no control over what modules get loaded or what their content is. I'll admit to a lack of details on my situation but not of consistency in my answers...
      Again, profile it.
      Always a good advice. Profiling with NYTProf prior to my original post is how I detected the source of my issue.
      Learning facts like that is part of the reason for reading the docs
      Another great piece of advice. I quote perlvar myself in my post so I think I pass :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://876357]
help
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 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found