"stress"-testing shell interpreters...
Sunday, 10. February 2008, 23:38:12
So here's the test script:
s=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $s)) "seconds to finish"
And the results:
$ bash -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $s)) "seconds to finish"'
bash took 53 seconds to finish
$ dash -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $s)) "seconds to finish"'
dash took 8 seconds to finish
$ zsh -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $sk)) "seconds to finish"'
zsh took 39 seconds to finish
$ ksh -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $s)) "seconds to finish"'
ksh took 14 seconds to finish
Intel P4 2.80 GHz, 1MB cache
bash: 3.1dfsg-8
dash: 0.5.4-6
ksh: 93s+20070628-1
posh: 0.6
zsh: 4.3.4-dev-7-3
... and posh's results? I killed the process after seven minutes









Anonymous # 11. February 2008, 02:03
Did you try to use Bash with C locale?
LANG=en_US.UTF-8 bash -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo "$0 took" $(($(date +%s) - $s)) "seconds to finish"'
bash took 43 seconds to finish
LANG=C bash -c 's=$(date +%s); c=0; while true; do if [ $c = 1000000 ]; then break; else c=$(($c+1)); fi; done; echo"$0 took" $(($(date +%s) - $s)) "seconds to finish"'
bash took 32 seconds to finish
I dont know if any other shell will also have a different execution time.
atomo64 # 11. February 2008, 03:37
the others don't differ at all with LANG=C
Anonymous # 11. February 2008, 14:52
There's a type in the zsh script. Instead of $sk it has to be $s.
Anyway, with zsh-4.3.5 it takes about 23 seconds on my Centrino Duo with 1.6 GHz and 1G RAM. Using LANG=C seems to have no effect. My default is en_US.utf8.
--Tassilo
Anonymous # 11. February 2008, 18:16
This reminds me of the perl "benchmark" (Note: not a benchmark) that we've been running on loads of machines. It's much like yours, and the results are available for all to see:-
http://www.hants.lug.org.uk/cgi-bin/wiki.pl?HugoRandomBenchmark
atomo64 # 12. February 2008, 02:01
seems like I accidentally inserted a 'k' while separating the test results (backed up with the fact that trying to run it that way you would get a zsh:1: bad math expression: operand expected at `')