in reply to EEK! sysread() is expensive!
in thread Last N lines from file (tail)

I'm just wondering if your reply relates to my answer also. I changed the sysread and sysseek calls to plain read and seek (and removed that last seek), and benchmarked my old and new versions, and got a huge performance hit (~3 cycles/sec with sys* calls, ~1100 cps w/o sys).
Update: And I checked clintp's answer with & w/o sys* calls, and it was ~5 cps with and ~4 w/o. This was all reading the last 400 lines from a 1000 line file, 10 bytes/line.

Replies are listed 'Best First'.
Re: Re: EEK! sysread() is expensive!
by chip (Curate) on Dec 22, 2001 at 04:35 UTC
    Well, sure, because a plain read() would have used stdio, which probably translated to the equivalant of sysread(4096) at least. If you're doing N reads of one byte, then change that to N reads of 4096 bytes, of course you'll have a slowdown ... and a wasteful one, since every time you read a block you use only one byte.

        -- Chip Salzenberg, Free-Floating Agent of Chaos