[m-rev.] diff: tools/speedtest -e

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Aug 23 13:43:31 AEST 2011


tools/speedtest:
	Allow the caller to specify what directory the tested command should be
	executed in.

	Convert to four-space indentation.

	Wrap all shell variable references.

Zoltan.

cvs diff: Diffing .
Index: speedtest
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/speedtest,v
retrieving revision 1.25
diff -u -b -r1.25 speedtest
--- speedtest	24 May 2011 09:14:12 -0000	1.25
+++ speedtest	23 Aug 2011 03:08:44 -0000
@@ -1,8 +1,9 @@
 #!/bin/sh
+# vim: ts=4 sw=4 et
 #
 # A program to test different versions of the compiler.
 
-usage="Usage: speedtest [-dstz] [-l | -1] [-g grade] [-o option]* [-c cmd] [-nN] [-ON] [-fFILE] batchname"
+usage="Usage: speedtest [-dstz] [-l | -1] [-e dir] [-g grade] [-c cmd] [-o option]* [-nN] [-ON] [-fFILE] batchname"
 
 single_modulelist="typecheck.m"
 # As of 13 oct 2010, these are the eight largest modules of the compiler.
@@ -29,6 +30,7 @@
 "
 cmd=""
 debug=false
+execdir="arena"
 grade="--grade asm_fast.gc"
 framesizefile=""
 modulelist="$short_modulelist"
@@ -44,71 +46,107 @@
 	case $1 in
 
 	-c|--cmd)
-		cmd="$2" ; shift ;;
+            cmd="$2"
+            shift
+            ;;
 	-c*)
-		cmd="` expr $1 : '-c\(.*\)' `" ;;
+            cmd="`expr $1 : '-c\(.*\)'`"
+            ;;
 
 	-d)
-		debug=true ;;
+            debug=true
+            ;;
+
+        -e)
+            execdir="$2"
+            shift
+            ;;
+        -e*)
+            execdir="`expr $1 : '-e\(.*\)'`"
+            ;;
 
 	-g)
-		grade="--grade $2" ; shift ;;
+            grade="--grade $2"
+            shift
+            ;;
 	-g*)
-		grade="--grade ` expr $1 : '-g\(.*\)' `" ;;
+            grade="--grade `expr $1 : '-g\(.*\)'`"
+            ;;
 
 	-f)
-		framesizefile="$2" ; shift ;;
+            framesizefile="$2"
+            shift
+            ;;
 	-f*)
-		framesizefile="` expr $1 : '-f\(.*\)' `" ;;
+            framesizefile="`expr $1 : '-f\(.*\)'`"
+            ;;
 
 	-l)
-		modulelist="$long_modulelist" ;;
+            modulelist="${long_modulelist}"
+            ;;
 
 	-1)
-		modulelist="$single_modulelist" ;;
+            modulelist="${single_modulelist}"
+            ;;
 
 	-n)
-		limit="$2" ; shift ;;
+            limit="$2"
+            shift
+            ;;
 	-n*)
-		limit="` expr $1 : '-n\(.*\)' `" ;;
+            limit="`expr $1 : '-n\(.*\)'`"
+            ;;
 
 	-o)
-		options="$options $2" ; shift ;;
+            options="${options} $2"
+            shift
+            ;;
 	-o*)
-		options="$options ` expr $1 : '-f\(.*\)' `" ;;
+            options="${options} ` expr $1 : '-f\(.*\)' `"
+            ;;
 
 	-O)
-		optlevel="-O$2" ; shift ;;
+            optlevel="-O$2"
+            shift
+            ;;
 	-O*)
-		optlevel="$1" ;;
+            optlevel="$1"
+            ;;
 
 	-s)
-		size=true ;;
+            size=true
+            ;;
 
 	-t)
-		table_io=true ;;
+            table_io=true
+            ;;
 
 	-z)
-		zip=true ;;
+            zip=true
+            ;;
 
-	-*)	echo "$0: unknown option \`$1'" 2>&1
-		echo $usage
-		exit 1 ;;
+        -*)
+            echo "$0: unknown option \`$1'" 2>&1
+            echo ${usage}
+            exit 1
+            ;;
 
-	*)	break ;;
+        *)
+            break
+            ;;
 
 	esac
 	shift
 done
 
-if test "$cmd" = ""
+if test "${cmd}" = ""
 then
-	cmd="mmc -C $optlevel $options $grade $modulelist"
+    cmd="mmc -C $optlevel ${options} $grade $modulelist"
 fi
 
 if test $# != 1
 then
-	echo $usage
+    echo ${usage}
 	exit 1
 fi
 
@@ -119,7 +157,7 @@
 
 if $zip
 then
-	trap 'gzip $root/batch/$batch.mercury_compile.*[0-9] > /dev/null 2>&1; exit 0' 0 1 2 3 15
+    trap 'gzip ${root}/batch/${batch}.mercury_compile.*[0-9] > /dev/null 2>&1; exit 0' 0 1 2 3 15
 fi
 
 if test -x /usr/ucb/echo
@@ -129,70 +167,72 @@
 	ECHO=echo
 fi
 
-for file in $files
+for file in ${files}
 do
-	case $file in
+    case ${file} in
 	*.gz)
-		gunzip $file
-		file=batch/`basename $file .gz`
+        gunzip ${file}
+        file=batch/`basename ${file} .gz`
 		;;
 	esac
 
-	paramfile=`echo $file | sed 's/mercury_compile/params/'`
-	if test -r $paramfile
+    paramfile=`echo ${file} | sed 's/mercury_compile/params/'`
+    if test -r ${paramfile}
 	then
-		cat $paramfile
+        cat ${paramfile}
 	fi
 
-	if $size
+    if ${size}
 	then
-		size $file
+        size ${file}
 	fi
 
-	MERCURY_COMPILER=$root/$file
+    MERCURY_COMPILER=${root}/${file}
 	export MERCURY_COMPILER
-	cd arena
+    cd ${execdir}
 	count=1
-	while test $count -le $limit
+    while test ${count} -le ${limit}
 	do
-		if test "$framesizefile" != ""
+        if test "${framesizefile}" != ""
 		then
-			rm $framesizefile > /dev/null 2>&1
+            rm ${framesizefile} > /dev/null 2>&1
 		fi
 
-		briefname=`echo "$file" | sed "s:batch/$batch.::"`
-		$ECHO -n "$briefname "
-		if $debug
+        briefname=`echo "${file}" | sed "s:batch/$batch.::"`
+        $ECHO -n "${briefname} "
+        if ${debug}
 		then
-			if $table_io
+            if ${table_io}
 			then
-				(echo "table_io start" ; echo "c" ) | $root/tools/dotime mdb $cmd
+                (echo "table_io start" ; echo "c" ) \
+                    | (cd ${execdir} ; ${root}/tools/dotime mdb ${cmd})
 			else
-				echo "c" | $root/tools/dotime mdb $cmd
+                echo "c" | (cd ${execdir} ; ${root}/tools/dotime mdb ${cmd})
 			fi
 		else
-			$root/tools/dotime $cmd
+            (cd ${execdir} ; ${root}/tools/dotime ${cmd})
 		fi
 
 		if test -s Deep.data
 		then
-			mv Deep.data ../batch/Deep.data.`basename $file .gz`.run$count
+            mv Deep.data \
+                ${root}/batch/Deep.data.`basename ${file} .gz`.run${count}
 		fi
 
-		if test "$count" -eq 1 -a "$framesizefile" != ""
+        if test "${count}" -eq 1 -a "${framesizefile}" != ""
 		then
 			echo
-			cat $framesizefile
+            cat ${framesizefile}
 			echo
 		fi
 
-		count=`expr $count + 1`
+        count=`expr ${count} + 1`
 	done
 
-	cd $root
-	if $zip
+    cd ${root}
+    if ${zip}
 	then
-		gzip $file
+        gzip ${file}
 	fi
 done
 
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list