OK, let's
not arbitrarily turn something into a function call that doesn't have to be, and, more importantly, let's recognize the overhead of loading a module:
use Benchmark qw(cmpthese);
cmpthese(-2, {
fs => sub { delete $INC{'File/Slurp.pm'}; require File::Slurp;
+ File::Slurp->import(); $x = read_file("foo") },
is => sub { $x = do { local (@ARGV, $/) = "foo"; <> }; }
});
---
$ perl5.6.0 test.pl
Benchmark: running fs, is, each for at least 2 CPU seconds...
fs: 3 wallclock secs ( 2.08 usr + 0.11 sys = 2.19 CPU) @ 26
+6.67/s (n=584)
is: 2 wallclock secs ( 1.16 usr + 0.86 sys = 2.02 CPU) @ 47
+311.39/s (n=95569)
Rate fs is
fs 267/s -- -99%
is 47311/s 17642%
And, yes, I am being a little tongue in cheek with that... but the point is: benchmarks are what you make of them.
------------
:Wq
Not an editor command: Wq
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.