Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

by Wonko the sane (Deacon)
on Mar 11, 2004 at 22:27 UTC ( #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?


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,

  • 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://335999]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-02-25 08:11 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.