Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Fast file reader

by AgentM (Curate)
on Mar 16, 2001 at 00:42 UTC ( [id://64775]=note: print w/replies, xml ) Need Help??


in reply to Fast file reader

Wouldn't it be easier to call setvbuf for a file handle and rely on stdio for the performance boost?
AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Replies are listed 'Best First'.
(tye)Re: Fast file reader
by tye (Sage) on Mar 16, 2001 at 01:07 UTC

    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")
      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://64775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found