From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d0e709e8abb8eab,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-03-09 04:18:13 PST Path: bga.com!news.sprintlink.net!cs.utexas.edu!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!epflnews!monnier From: "Stefan Monnier" Newsgroups: comp.unix.osf.osf1 Subject: sh too demanding for an alpha ? Date: 8 Mar 1995 14:49:17 GMT Organization: Ecole Polytechnique Federale de Lausanne Message-ID: <3jkg5d$lrr@info.epfl.ch> NNTP-Posting-Host: didec9.epfl.ch Originator: monnier@didec9.epfl.ch I have a trivial print script that runs nenscript/lpspr/lpr. It really doesn't do much. But after the few initializations, I have a 'for arg do' line which takes more than a second to execute (most of it is paging, of course) even though the machine is a simple alpha (3000/400) with 64M of main memory and nothing serious running. It's definitely not due to the machine (I tried on a bunch of them, some recently rebooted). They are running osf/1 2.1. example: man/man1-0> time print -help print { [-+124] [-+h] [-Sx] [-Px] [-Tx] files } -1 : single sided, one page per side -2 : single sided, two pages per side +2 : double sided, one page per side -4 : double sided, two pages per side (default) -h : don't print burst page (broken) +h : print burst page -Sx : select paper size 'x' (default = 'a4') -Tx : select paper tray 'x' (default = 'bottom') -Px : select printer 'x' (default = 'lps32') 0.017u 0.170s 0:01.93 9.3% 0+2k 32+0io 25pf+0w Interestingly, bash doesn't have this problem (it runs in less than 0.2 seconds). And also, if the "useless" part of the loop is commented out, leaving only the 'echo's, the speed comes back to normal. What the hell does sh do with that for loop and the big switch ? The script is appended. Stefan ---- #!/bin/sh size="2" sides="2" header="" headers="" filter="" printer="$PRINTER" tray="bottom" papersize="a4" for arg do case $arg in -T* ) tray=`echo $arg | sed -e 's/^-T//'` ;; -S* ) papersize=`echo $arg | sed -e 's/^-S//'` ;; -P* ) printer=`echo $arg | sed -e 's/^-P//'` ;; +h ) header="" headers= ;; -h ) header="-h" headers="-h" ;; -1 ) size="1" sides="1" ;; -2 ) size="2" sides="1" ;; +2 ) size="1" sides="2" ;; -4 ) size="2" sides="2" ;; -* ) echo "print { [-+124] [-+h] [-Sx] [-Px] [-Tx] files }" echo " -1 : single sided, one page per side" echo " -2 : single sided, two pages per side" echo " +2 : double sided, one page per side" echo " -4 : double sided, two pages per side (default)" echo " -h : don't print burst page (broken)" echo " +h : print burst page" echo " -Sx : select paper size 'x' (default = '$papersize')" echo " -Tx : select paper tray 'x' (default = '$tray')" echo " -Px : select printer 'x' (default = '$printer')" exit ;; * ) if [ x`sed -n -e '1s/^%!.*$/postscript/p' -e 2q $arg` = "xpostscript" ]; then filter="lpspr -N$size" else case $size in 1 ) filter="nenscript -G -fCourier8 -p -" ;; 2 ) filter="nenscript -G -fCourier6 -2r -p -" ;; esac fi case $printer in *:* ) lpr=`echo $printer | sed -e 's/^\(.*\):\(.*\)$/rsh \1 lpr -P\2/'` ;; * ) lpr="lpr -P$printer" ;; esac if [ "${header}x" = "-hx" ]; then $filter $arg | lpspr -K$sides -I$tray -S$papersize | $lpr "$header" else $filter $arg | lpspr -K$sides -I$tray -S$papersize | $lpr -J $arg fi header="$headers" ;; esac done -- -------------------------------------------------------------------- -- Suicidez-vous jeune, vous profiterez plus longtemps de la mort -- --------------------------------------------------------------------