"Sander van Dijk" <[EMAIL PROTECTED]> writes:

> I wouldn't be surprised if using bc the smart way is actually faster,
> but the machine I'm testing on is too fast to measure the difference
> between the various approaches; could you test how fast this is?
>
> bc << !
> for(i = 1000; i > 0; i--)
>         n = n + i
> print n
> !

,----
| $ time bc << !
| > for(i = 1000; i > 0; i--)
| >         n = n + i
| > print n
| > !
| 500500
| real  0m0.003s
| user  0m0.000s
| sys   0m0.000s
`----

So this is the fastest way for doing that kind of calculation.  However,
this doesn't append to the »real life« example of Hugo's netmon.sh,
where he does simple calculations like  

$(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc)

Even if bc's calculations are much faster than those of the shell, the
cost of the fork is much too high.

Best regards,
 olli
-- 
http://www.sopos.org/olli/ GnuPG-Key: gpg --recv-keys 0x9A00D827
GnuPG-Fingerprint: F27A BA8C 1CFB B905 65A8  2544 0F07 B675 9A00 D827
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Reply via email to