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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |