"Sander van Dijk" <a.h.vandijk_AT_gmail.com> 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.htmlReceived on Fri Jul 04 2008 - 11:17:11 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:53:17 UTC