PoisonBit per lavori che sta facendo a voluto fare dei test per decidere quale shell usare, a questo proposito ha fatto un test per verificarne le performance. Io ho modificato questo script aggiungendo ulteriori shell. Lo script è il seguente:
#!/bin/bash
testdir=$HOME/test
mkdir -p "$testdir"
printf '#!/bin/dash --\n\n' > "$testdir/dash"
printf '#!/bin/bash --\n\n' > "$testdir/bash"
printf '#!/bin/ksh --\n\n' > "$testdir/ksh"
printf '#!/bin/csh --\n\n' > "$testdir/csh"
printf '#!/bin/zsh --\n\n' > "$testdir/zsh"
chmod +x "$testdir"/*
for i in 1 10 100 1000 10000
do
for shell in 'bash' 'dash' 'ksh' 'csh' 'zsh'
do
result=''
printf "$shell\t$i\t"
result="$(
(time for ((x=0; x < $i; x++));
do
"$testdir/$shell";
done) 2>&1 | awk -F\ '/real/{print $2}'
)"
printf "$result\n"
done
printf -- '-------------------------\n'
done
salviamo come test-shell.sh
$ chmod a+x test-shell.sh
lo lanciamo con:
$ ./test-shell.sh
come si può vedere dai risultati il più performante è dash, ma questo era prevedibile, quello che è interessante sono proprio le differenze in termini numerici tra di loro.
edmond@debianbox:~$ ./testshell.sh
bash 1 0m0.002s
dash 1 0m0.001s
ksh 1 0m0.002s
csh 1 0m0.004s
zsh 1 0m0.003s
————————-
bash 10 0m0.021s
dash 10 0m0.009s
ksh 10 0m0.019s
csh 10 0m0.039s
zsh 10 0m0.032s
————————-
bash 100 0m0.202s
dash 100 0m0.088s
ksh 100 0m0.181s
csh 100 0m0.380s
zsh 100 0m0.294s
————————-
bash 1000 0m1.900s
dash 1000 0m0.867s
ksh 1000 0m1.793s
csh 1000 0m3.759s
zsh 1000 0m3.078s
————————-
bash 10000 0m19.689s
dash 10000 0m8.577s
ksh 10000 0m17.453s
csh 10000 0m36.365s
zsh 10000 0m29.948s
il vincitore è Debian Almquist Shell (dash)