On Thu, Sep 10, 2009 at 8:38 AM, Raymond Wong<raym...@gmail.com> wrote: > Hi, > > Thanks for taking a look. > > The SPARC system is a Sun V440 with 4 CPUs and 16GB of RAM. The normal CPU > load is about 50% and minimal disk activity. > > What the script does is to go through a text file and get the beginning & > ending line # for printing the pages specified. The part of the script that > is taking over 20min on Solaris is quoted here. > > I ran the script in the /tmp folder on both the Solaris & Linux systems. > > > [code] > #!/usr/bin/bash > # > # set -x > # > # > authen=$1 > > prt_req_id=82044908 > page_from=200 > page_to=250 > printer=nec_p2000 > copies=0 > printed=1 > > file_dir=./ > org_file=o${prt_req_id}.out > dest_file=o${prt_req_id}.prt > line=0 > page=1 > BeginLine=1 > EndLine=0 > page_to=`echo ${page_to} + 1 | bc` > > echo `date` > echo "Calculating line numbers." > > while read a > do > line=`echo ${line} + 1 | bc` > if [ "`echo ${a} | cut -b1`" = ^L ] > then > page=`echo ${page} + 1 | bc` > if [ ${page_from} -eq ${page} ] > then > BeginLine=`echo ${line} | bc` > fi > if [ ${page_to} -eq ${page} ] > then > EndLine=`echo ${line} - 1 | bc` > break > fi > fi > done<<list > `cat ${file_dir}/${org_file}` > list > [/code]
Ouch. Don't increment variables like that. As a quck test using ksh to count the line in my messages file (about 1600). Doing it this way: while read a do line=`echo ${line} + 1 | bc` done takes real 8.855 user 1.440 sys 6.254 while doing it this way: while read a do line=$(($line+1)) done takes real 0.062 user 0.054 sys 0.006 as you can see, the difference is substantial. -- -Peter Tribble http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/ _______________________________________________ perf-discuss mailing list perf-discuss@opensolaris.org