X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Mon, 27 Dec 2004 10:25:29 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-ID: <01c4ebed$Blat.v2.2.2$c5f598c0@zahav.net.il> Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=ISO-8859-1 X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 2.2.2 In-reply-to: <8edus09uvkr9or13giuvdflk4ogin5q2l1@4ax.com> (message from Brian Inglis on Sun, 26 Dec 2004 22:13:39 GMT) Subject: Re: DREADED fseek References: <6a7us0he1s9ml2djpp5tlm48lod92eei5c AT 4ax DOT com> <8edus09uvkr9or13giuvdflk4ogin5q2l1 AT 4ax DOT com> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Brian Inglis > 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).