[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] beauty vs. brains



At 10:30 AM 3/15/00 -0500, Jeff Pinyan wrote:
>I've often done
>
>   $file = do { local $/, <FILE> };
>
>when I wish to slurp a file into a scalar.  However, I recently realized
>that doing
>
>   read(FILE, $file, -s FILE);
>
>can be done in NEARLY half the time.

To settle a bet on this a while back, I put together a test script
that used ktrace on FreeBSD to track the actual number of underlying
kernel read calls. It turned out that Perl's read() results in a
sequence of kernel read()s, each for 0 < n <= BLOCKSIZE byte blocks.

Perl's sysread() uses a single kernel read(), at least on FreeBSD.

Dave



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe