From: Clifford Heath Date: 2002-06-21T13:48:52+09:00 Subject: Re: Why is I/O slow? Clifford Heath wrote: > Anyhow, thanks to Radek for the advice, I've got 1.6.7 and the performance > of sysread seems comparable to read now. Sorry, must have tested the wrong version somehow - read is still slow. $ time ruby cat_read.rb /tmp/ten_megabytes > /dev/null real 0m1.259s user 0m1.210s sys 0m0.050s $ time ruby cat_sysread.rb /tmp/ten_megabytes > /dev/null real 0m0.148s user 0m0.080s sys 0m0.060s One thing I don't get: my C program takes 65ms, but Perl and /bin/cat take only 35ms. Perl and C programs follow. BTW a larger buffer than 65K slows both down - cache size. # cat.pl my $buf; my $r; while (sysread(STDIN, $buf, 65536) > 0) { print $buf } main() { int r; char buf[65536]; while ((r = read(0, buf, sizeof(buf))) > 0) write(1, buf, r); } Thoughts? -- Clifford Heath