Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: use vs. require in string eval?

by Wonko the sane (Deacon)
on Mar 11, 2004 at 22:27 UTC ( [id://335999]=note: print w/replies, xml ) Need Help??


in reply to Re: use vs. require in string eval?
in thread use vs. require in string eval?

Hello,

While I agree that require's are probably a tad faster than uses's,
I am not sure that trying to benchmark these like this is really a valid test.
Is'nt it true that once you require(or use) a module, perl knows that you have done this,
and shorts out any further calls for that same module? Hence you can have multiple requires
peppered throughout your App, and it does not make your performace suffer,
even if the statement is hit multiple times.

Best Regards,
Wonko

  • Comment on Re: Re: use vs. require in string eval?

Replies are listed 'Best First'.
Re: Re: Re: use vs. require in string eval?
by perrin (Chancellor) on Mar 11, 2004 at 22:55 UTC
    First of all, there is no way this could be taking significant amounts of time unless the app is doing basically nothing. However, it is not correct to say that perl "shorts out any further calls for that same module." It at least involves perl running some code that will check %INC for the module in question, and with "use" it would also involve running an import(), although a use statement typically only happens once because it is a virtual BEGIN block.

    So, what I'm saying is that require and use definitely do take some time inside of a string eval, even if you have already run them before, and there is a difference in the amount of time they take.

Log In?
Username:
Password:

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

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

    No recent polls found