Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.6.2.17 $; site ee.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!inuxc!pur-ee!ee!malcolm From: malcolm@ee.UUCP Newsgroups: net.unix Subject: Re: Speed of read vs. fread Message-ID: <67400002@ee.UUCP> Date: Mon, 21-Jan-85 19:59:00 EST Article-I.D.: ee.67400002 Posted: Mon Jan 21 19:59:00 1985 Date-Received: Wed, 23-Jan-85 05:07:17 EST References: <626@ihlts.UUCP> Lines: 24 Nf-ID: #R:ihlts:-62600:ee:67400002:000:940 Nf-From: ee!malcolm Jan 21 19:59:00 1985 /* Written 9:36 pm Jan 19, 1985 by lied@ihlts in ee:net.unix */ Which is faster, read/write or fread/fwrite? Depends on what you are doing. If you are doing single character IO then by all means use fread/fwrite. The time it takes to put the character in the buffer is insignificant to the expense of a syscall. On the other hand large chunks of IO (several BUFSIZ's at a time) are much more efficient with read/write. One of my research programs saved many seconds of CPU time by using write() to output large matrices (100k bytes) for debugging. The question is where to draw the line. I would recomend that in general to use fread/fwrite. If you are reading/writing more than 5 or 10k at a time (one call to read/write) then you'll start saving a little time by using read/write. Charter member of the Purdue team to stamp out unnecessary sys-calls. Malcolm pur-ee!malcolm malcolm@purdue.arpa