Created
January 23, 2012 15:04
-
-
Save mlafeldt/1663556 to your computer and use it in GitHub Desktop.
[Shell] Simple performance test for POSIX-compliant shells
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ time env -i bash shell-perf.sh | |
Forking 1000 bash subshells........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | |
real 0m10.797s | |
user 0m11.250s | |
sys 0m1.380s | |
$ time env -i dash shell-perf.sh | |
Forking 1000 dash subshells........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | |
real 0m4.253s | |
user 0m9.590s | |
sys 0m0.550s | |
$ time env -i zsh shell-perf.sh | |
Forking 1000 zsh subshells........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ | |
real 0m8.384s | |
user 0m9.240s | |
sys 0m2.070s | |
$ uname -a | |
Linux pc-mlafeldt 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:32:42 UTC 2011 x86_64 GNU/Linux | |
$ grep "^model name" /proc/cpuinfo | |
model name : Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz | |
model name : Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz | |
model name : Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz | |
model name : Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Simple performance test for POSIX-compliant shells | |
# | |
# Usage: time env -i <shell> shell-perf.sh [<num subshells>] | |
# | |
# Written by Mathias Lafeldt <mathias.lafeldt@gmail.com> | |
shell="$(ps -o pid,command | awk "\$1 == $$ { print \$2 }")" | |
forks=${1:-1000} | |
echo -n "Forking $forks $shell subshells" | |
for i in $(seq 1 $forks); do | |
"$shell" -c 'echo -n .; j=1; while [ $j -le 1000 ]; do j=$(($j+1)); done' | |
done | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More results:
Thanks to Stefan S.