1 | #
|
---|
2 | # Simple performance test for POSIX-compliant shells
|
---|
3 | #
|
---|
4 | # Usage: time env -i <shell> shell-perf.sh [<num subshells>]
|
---|
5 | #
|
---|
6 | # Written by Mathias Lafeldt <mathias.lafeldt@gmail.com>
|
---|
7 |
|
---|
8 | # for linux OS
|
---|
9 | #shell="$(ps -o pid,command | awk "\$1 == $$ { print \$2 }")"
|
---|
10 |
|
---|
11 | # for OS/2
|
---|
12 | xpid=$(printf %X $$)
|
---|
13 | shell="$(pstat /p:$xpid | grep ^$xpid | awk "{ print \$4 }")"
|
---|
14 |
|
---|
15 | forks=${1:-1000}
|
---|
16 |
|
---|
17 | echo -n "Forking $forks $shell subshells"
|
---|
18 |
|
---|
19 | for i in $(seq 1 $forks); do
|
---|
20 | "$shell" -c 'echo -n .; j=1; while [ $j -le 1000 ]; do j=$(($j+1)); done'
|
---|
21 | done
|
---|
22 |
|
---|
23 | echo ""
|
---|