Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* sh too demanding for an alpha ?
@ 1995-03-08 14:49 Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 1995-03-08 14:49 UTC (permalink / raw)



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 --
--------------------------------------------------------------------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-03-08 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-03-08 14:49 sh too demanding for an alpha ? Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox