read in /bin/sh appears to be VERY cpu costly.
Brandon S. Allbery KB8JRR/AA
allbery at NCoast.ORG
Sat May 11 11:33:54 AEST 1991
As quoted from <1991May8.013013.29811 at brolga.cc.uq.oz.au> by ggm at brolga.cc.uq.oz.au (George Michaelson):
+---------------
| simple tests using time on a shellscript of:
|
| while 1
| do
| read INP
| echo $INP
| done
|
| seem to suggest that read is incredibly expensive on the CPU.
+---------------
Do you know that it's "read" that is expensive? The other possibilities are:
"while/do/done" and "echo". Not to mention that "while 1" returns "1: not
found" on my system (admittedly, not a Sun 4), and the cost of interpolating
and expanding the "echo" command line.
A better test of the speed of "read" is to time a script containing only
"read" statements. Also time an empty script so you can factor out the shell
startup time, for still better accuracy.
(Note: if your timing tests did in fact take this into account, you should
probably have said so.)
++Brandon
--
Me: Brandon S. Allbery Ham: KB8JRR/AA 10m,6m,2m,220,440,1.2
Internet: allbery at NCoast.ORG (restricted HF at present)
Delphi: ALLBERY AMPR: kb8jrr.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery KB8JRR @ WA8BXN.OH
More information about the Comp.unix.shell
mailing list