C/UNIX low level I/O
James da Silva
jds at mimsy.UUCP
Thu Nov 3 02:05:25 AEST 1988
In article <6695 at pyr.gatech.EDU> david at pyr.gatech.edu (David Brown) writes:
>
> ... But this ay, I do a separate 'write' for every word in the
> list, and a 'write' for the spaces between and the newlines. Like this:
>
[ pseudocode showing writes for each word and space, then for the newline ]
>
> My question: is there a better way to do this? I've thought of using
> higher-level I/O routines like fprintf, but I think they would be
> less efficient. But less efficient than what I'm doing now?
If you don't need the formatting capabilities of fprintf, try using fputs.
I think you will see a significant speed boost because the stdio library
buffers your output rather than doing a system call for each word.
You can get even more juice by buffering it yourself, since you don't have
to be as general as stdio does. But then you have to be sure to pick a
good buffer size for your system...
- Jaime
----------------------------------------------------------------------
path: uunet!mimsy!jds James da Silva
domain: jds at mimsy.umd.edu
More information about the Comp.unix.questions
mailing list