in reply to Re: Fast file reader
in thread Fast file reader

Actually, on "non broken" platforms, Perl's I/O is more efficient than stdio.h I/O because it knows how to peak inside stdio's internal structures to avoid extra copying of data.

Unfortunately, Linux is a "broken" platform in this regard so Perl's native readline (<>) is 4-times slower than it should be.

I suspect benchmarking this code will show that it is slower than plain <IN> when run on many old-style Unix platforms but faster than <IN> on Linux.

I'd like to encourage effort toward "fixing" Perl's I/O optimizations for Linux and other platforms (written in C).

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Fast file reader
by Malkavian (Friar) on Mar 16, 2001 at 04:02 UTC
    Thanks tye.
    I'd been wondering for a while why a read kludge like this would be faster than Perl for IO.
    Saves me asking the question in another post. :)
    I'll be keeping my eyes open for the fix if/when it appears, as a huge amount of my current work involves Perl and file IO.

    Malk
      You may want to use sysread() to spped up file I/O. Huameng