Mail Archives: djgpp/2004/12/27/03:33:48
> From: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT Invalid>
> Date: Sun, 26 Dec 2004 22:13:39 GMT
>
> If you use setvbuf() *immediately after fopen()* to increase your
> buffer size to 4/8/16KB, that technique may work even faster.
Not with DJGPP. Since file I/O is done with DOS system calls, data is
moved via the transfer buffer, whose size is 16KB by default.
Consequently, any changes in buffer size via `setvbuf' will not yield
any significant effect, except for ridiculously small arguments to
`setvbuf', unless you also change the size of the transfer buffer (can
be enlarged up to 65254 bytes).
If memory serves, I once tried to play with `setvbuf' and transfer
buffer changes to speed up I/O, but couldn't see any significant
improvements. But you are welcome to try again and report the
results.
> The fastest way is fstat() to get the file length, malloc() a file
> length buffer (or perhaps some portion for a very large file),
> setvbuf() to the buffer, and do a single fread, then play in memory.
Since there's a transfer buffer in between, that single `fread' will
still be done in chunks, unless the file is less than the transfer
buffer size (16KB by default).
- Raw text -