I tried the following piece of code on W2000 using a 2.4MB file
s = Time.new
data = File.open(“xx.data”,“rb”).read
e = Time.new
p e-s
Time to perform 6.5 seconds
Then I changed it to
s = Time.new
data = File.open(“xx.data”,“rb”).sysread( File::stat(“xx.data”).size )
e = Time.new
p e-s
Time to perform .01 seconds… THATS RIGHT .01 seconds
This was using a stable snapshot from about a month ago. And yes, I know
that sysread is a low level function, but I never expected an improvement of
650X.
Any thoughts?
Allen Mitchell
Could it be that there are some file IO caching effects that you’re seeing here?
At the very least, I’d reverse the order of the tests as well as have several
different files (could be identical files) to test.
···
On Tue, Oct 08, 2002 at 01:26:27AM +0900, Allen Mitchell wrote:
This was using a stable snapshot from about a month ago. And yes, I know
that sysread is a low level function, but I never expected an improvement of
650X.
–
Alan Chen
Digikata LLC
http://digikata.com
I think you are somewhat right. I created new files and then shutdown the
system to clear the cache. On a retry, the times changed to .25 seconds and
.02 seconds. I think that something else was causing the extreme delay on
the first one.
Guess I should have tested more before commenting. Thanks for the comments.
···
-----Original Message-----
From: Alan Chen [mailto:alan@digikata.com]
Sent: October 7, 2002 14:06
To: ruby-talk ML
Subject: Re: File.read Vs. File.sysread performance…
On Tue, Oct 08, 2002 at 01:26:27AM +0900, Allen Mitchell wrote:
This was using a stable snapshot from about a month ago. And yes, I know
that sysread is a low level function, but I never expected an improvement
of
650X.
Could it be that there are some file IO caching effects that you’re seeing
here?
At the very least, I’d reverse the order of the tests as well as have
several
different files (could be identical files) to test.
–
Alan Chen
Digikata LLC
http://digikata.com