#!/bin/sh # z/OS: what file tagging and conversion cost (n/a elsewhere). # # Run on z/OS against /bin/sh and bash: sh bench/run.sh ./zash /bin/sh bash # Each part does the same work in every shell; the output is only counts, # so it compares equal across shells. The scratch files are created in # the current directory (bench/run.sh runs each bench in a work dir). [ "$(uname -s)" = OS/390 ] || exit 3 command -v chtag >/dev/null 2>&1 || exit 3 # 1. Redirections creating new files: untagged (the default) ... i=0 while [ $i -lt 1000 ]; do echo line >u$i i=$((i + 1)) done # ... and with a deferred text tag on each new file. _TAG_REDIR_OUT=TXT export _TAG_REDIR_OUT i=0 while [ $i -lt 1000 ]; do echo line >t$i i=$((i + 1)) done unset _TAG_REDIR_OUT rm -f u* t* # 2. Sourcing a script tagged ISO8859-1 and one tagged IBM-1047: one of # them needs conversion whichever character set the shell is. _TAG_REDIR_OUT=BIN printf '\145\143\150\157\040\170\012' >s819 chtag -tc ISO8859-1 s819 _TAG_REDIR_OUT=BIN printf '\205\203\210\226\100\247\025' >s1047 chtag -tc IBM-1047 s1047 n=0 i=0 while [ $i -lt 500 ]; do . ./s819 >/dev/null . ./s1047 >/dev/null n=$((n + 2)) i=$((i + 1)) done echo "sourced $n" # 3. Here-documents read by a builtin. i=0 while [ $i -lt 2000 ]; do read -r x </dev/null i=$((i + 1)) done echo "pipes $i" i=0 while [ $i -lt 200 ]; do x=$(uname -s) i=$((i + 1)) done echo "cmdsubs $i $x"