I originally got it into my head that setting the size for slurping was a good thing after reading Slurp-Eazy. I seem to recall that it seemed quicker on my old portable under 5.6.1.

However, looking again now under 5.8.4, the picture is both mixed and confusing:

(ordered both ways to eliminate the possibilty of "first run bias")

#! perl -slw use strict; use Benchmark qw[ cmpthese ]; open our $raw, '<:raw', $ARGV[ 0 ] or die $!; open our $txt, '< ', $ARGV[ 0 ] or die $!; our $s = -s $raw; cmpthese -3, { d_raw_trad => q[ my $data = do{ local $/; <$raw> }; ], c_raw_size => q[ my $data = do{ local $/ = \$s; <$raw> }; ], b_txt_trad => q[ my $data = do{ local $/; <$txt> }; ], a_txt_size => q[ my $data = do{ local $/ = \$s; <$txt> }; ], }; __END__ [15:46:09.53] P:\test>440395 100.dat Rate raw_size raw_trad txt_trad txt_size a_raw_size 7969/s -- -87% -88% -96% b_raw_trad 63136/s 692% -- -2% -69% c_txt_trad 64282/s 707% 2% -- -69% d_txt_size 206315/s 2489% 227% 221% -- [15:53:19.11] P:\test>440395 100.dat Rate c_raw_size d_raw_trad b_txt_trad a_txt_size c_raw_size 7855/s -- -87% -88% -96% d_raw_trad 62625/s 697% -- -4% -70% b_txt_trad 65166/s 730% 4% -- -68% a_txt_size 206449/s 2528% 230% 217% --

Now quite why slurping a file in text-mode would be faster (and soo much faster!) than doing so in raw mode leaves me at a total loss for an explaination. Seems that I should reassess what I thought I once knew about Perl IO-layers and performance.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

In reply to Re^3: Binary files by BrowserUk
in thread Binary files by amt

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.