First of all your test cases must be simple and focused, so that you compare those two IO methods directly, and don't add anything on top. Otherwise your test cases are not fair.

I have tested the following two cases on windows xp:

use strict; use warnings; my $t0 = time(); for (1..10) { open(F, "<:utf8", "noname2.txt"); while (<F>) { ; } close(F); } print time() - $t0;

And

use strict; use warnings; my $t0 = time(); for (1..10) { open(F, "<", "noname2.txt"); while (<F>) { ; } close(F); } print time() - $t0;

Both read a 34M utf file. The traditional one took 8-9 seconds, and the utf8 layer one took 11 seconds. So the one with the utf8 layer is slower as expected.

Secondly, should you expect the layered PerlIO be faster? No. And other monks have already provided good reasons above.

Go beyond Perl, I will take Java IO as an example - some sort of opposite example. Java was famous for its "layers" - layered design everywhere. The latest Java versions started to support a rawer IO method, and the IO speed is significantly improved. Was that expected? Yes that was expected.


In reply to Re: PerlIO slower than traditional IO? by pg
in thread PerlIO slower than traditional IO? by saintmike

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.