www.delorie.com/djgpp/faq/performance/fileio.html   search  
I measured time required to read a 10 MByte file in DJGPP and in Borland C. It took djgpp program 20 seconds to do it, while Borland did it in just 12. Isn't that HORRIBLY slow performance??

I tried to improve djgpp I/O throughput by defining larger buffer size for buffered I/O with a call to setvbuf(), but that had no effect. Why is that?

Doing I/O from protected-mode programs requires that low-level library functions move the data between the extended memory and low memory under 1 MByte mark, where real-mode DOS can get at it. As of version 1.12, djgpp moves data in chunks of 4 KB, so defining a buffer larger than that won't gain anything. This rather small size of the transfer buffer is the main (but not the only) reason for relatively low I/O throughput under djgpp. In version 2.0, the size of transfer buffer will be customizable up to a maximum of 64 KB.

That said, I would like to point out that waiting another 8 seconds for reading a 10 MByte file isn't that bad: it is indeed almost twice as long as you can do under DOS, but it's only 8 seconds... Besides, most programs read and write files which are only a few hundreds of kilobytes, and those will suffer only a minor slow-down.

  webmaster     delorie software   privacy  
  Copyright © 1995     Updated Feb 1995