home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1467 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  60 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Message-ID: <w+RYXMD4FC8aRz1@_crisi.blackbox.shnet.org>
  3. From: CRISI@BLACKBOX.shnet.org (Christian)
  4. Path: blackbox.shnet.org!CRISI
  5. Organization: .oO PHANTASM Oo.
  6. Subject: Re: fastest file read method ??
  7. Date: Sun, 14 Jan 1996 13:41:27 +0100
  8. X-Mailer: MicroDot 1.10 [REGISTERED 004fc8]
  9. References: <w9YbsMD4ACazz9@jeff.dame.shnet.org>
  10. X-Gateway: ZCONNECT US genepi.shnet.org [UNIX/Connect v0.71]
  11. MIME-Version: 1.0
  12. Content-Type: text/plain; charset=ISO-8859-1
  13. Content-Transfer-Encoding: 8bit
  14.  
  15. It was 11.01.1996 at 20:53:48 when JEFF@DAME.SHNET.ORG (Joerg Fenin)
  16. wrote about "fastest file read method ??":
  17. JF> Hi!
  18. JF> 
  19. JF> What is the fastest way to read a file ?
  20. JF> 
  21. JF> I used fread() and fgets() from the sc.lib of SAS/C, then I used
  22. JF> FRead() from dos.library but both routines seem to be rather slow
  23. JF> (FRead() was even slower than fread()).
  24. JF> 
  25. JF> Is there anything else I could use?
  26.  
  27. Hello Jeff,
  28.  
  29. fread(), fwrite(), fgets() and their AmigaDOS counterparts are all
  30. routines for buffered I/O. This means they have an internal buffer
  31. that must be maintained, and if you always wirte small amounts of
  32. data, the whole may become slow in relation to the speed of the
  33. storage medium, especially if you write to a fast one. The faster your
  34. storage medium is, the less speed increase there will be when writing
  35. small amounts of data along with buffered I/O.
  36.  
  37. fread() and fwrite() are probably faster than FRead() and FWrite()
  38. because they seem to use a more clever way of buffering along with
  39. using non-buffered AmigaDOS functions (i.e.  Read()/Write()).
  40.  
  41. If you want to use faster buffered I/O without using fread() and
  42. fwrite(), you will have to write your own buffering routine.  If you
  43. don't need buffered I/O (e.g.  if you read/write large memory blocks
  44. or if your CPU isn't much faster than your storage medium, e.g. if you
  45. write to a device in RAM like RAM:, RAD: or FFx: with FMS: assigned to
  46. RAM:), it's better to go without buffered I/O.
  47.  
  48. BTW:  With SetVBuf()/setvbuf() you can set the type of buffering to
  49. either a fixed block size (for binary data) or to reading ahead resp.
  50. delaying the write operation until a \n appears (for ASCII data) or to
  51. no buffering at all (as far as I remember), but I assume you also
  52. experimented with this.
  53.  
  54. Greetings
  55.  
  56. --
  57. Christian Wasner (CRISI/ PHANTASM)
  58. crisi@blackbox.shnet.org 
  59. Sorry, but you haven't won a cookie in today's lottery
  60.