On 8/30/2011 11:59 AM, Andrei Alexandrescu wrote:
Unless the OS issues speculative reads (which I don't think it does for either
files or sockets), any time spent in write() is a net loss for reading speed.
Now, if write is buffered and the buffers are flushed asynchronously, calls to
write() would be instantaneous. I'm not sure to what extent the major OSs do
that, and for what types of files.

The way to test this is to read file by 4096 byte chunks forwards, and compare that with the speed of reading it backwards.

The OS will try to cache the file in memory between runs, so to defeat this means the file has to be on a removable drive (I use an SD card) and pull the drive out and reinsert it between each test.

Reply via email to