Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
There is practically no difference between the two. Your benchmark is flawed, here is a correction (only the addition of delete $INC{'CGI.pm'}; is required):
use Benchmark 'cmpthese'; use CGI(); undef %CGI::; delete $INC{'CGI.pm'}; cmpthese( shift, { use => sub { eval "use CGI();"; undef %CGI::; delete $INC{'CGI.pm'}; return (); }, require => sub { eval "require CGI;"; undef %CGI::; delete $INC{'CGI.pm'}; return (); }, }); __END__ $$ perl eval.use.v.eval.require.pl -3 Benchmark: running require, use, each for at least 3 CPU seconds... require: 3 wallclock secs ( 3.09 usr + 0.13 sys = 3.22 CPU) @ 37 +.28/s (n=120) use: 3 wallclock secs ( 3.06 usr + 0.17 sys = 3.23 CPU) @ 37 +.11/s (n=120) Rate use require use 37.1/s -- -0% require 37.3/s 0% -- $$ perl eval.use.v.eval.require.pl -5 Benchmark: running require, use, each for at least 5 CPU seconds... require: 5 wallclock secs ( 5.14 usr + 0.14 sys = 5.28 CPU) @ 37 +.31/s (n=197) use: 5 wallclock secs ( 5.05 usr + 0.25 sys = 5.30 CPU) @ 37 +.19/s (n=197) Rate use require use 37.2/s -- -0% require 37.3/s 0% -- $$ perl eval.use.v.eval.require.pl 50 Benchmark: timing 50 iterations of require, use... require: 1 wallclock secs ( 1.30 usr + 0.03 sys = 1.33 CPU) @ 37 +.65/s (n=50) use: 1 wallclock secs ( 1.31 usr + 0.03 sys = 1.34 CPU) @ 37 +.23/s (n=50) Rate use require use 37.2/s -- -1% require 37.7/s 1% -- $$ perl eval.use.v.eval.require.pl 100 Benchmark: timing 100 iterations of require, use... require: 3 wallclock secs ( 2.61 usr + 0.06 sys = 2.67 CPU) @ 37 +.41/s (n=100) use: 2 wallclock secs ( 2.63 usr + 0.05 sys = 2.67 CPU) @ 37 +.43/s (n=100) Rate require use require 37.4/s -- -0% use 37.4/s 0% -- $$

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Re: use vs. require in string eval? by PodMaster
in thread use vs. require in string eval? by lachoy

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

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

    No recent polls found