Re: [dwm] dwm with dzen status bar

From: Sander van Dijk <a.h.vandijk_AT_gmail.com>
Date: Thu, 3 Jul 2008 16:31:06 +0200

On 7/3/08, Oliver Heins <olli_AT_sopos.org> wrote:
> Just a little remark about your netmon.sh script:
>
> ,----
> | ~$ time (n=0; for i in {1000..1}; do n=`echo "$n+$i"|bc`; done; echo $n)
> | 500500
> |
> | real 0m15.812s
> | user 0m0.532s
> | sys 0m15.449s
> | ~$ time (n=0; for i in {1000..1}; do n=$(($n+$i)); done; echo $n)
> | 500500
> |
> | real 0m0.015s
> | user 0m0.016s
> | sys 0m0.000s
> `----
>
> I don't know if arithmetic evaluation is a bashism, but I think the
> costs for using bc are quite high. However, I the let syntax (e.g.,
> »let "n = n +i"«) should work with all posix-shells and therefore be
> portable.

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
!

Greetings, Sander.
Received on Thu Jul 03 2008 - 16:31:11 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:53:13 UTC