#!/bin/csh
#*---------------------------------------------------------------------*/
#*    serrano/prgm/project/bigloo/benchmarks/1-bench ...               */
#*                                                                     */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Dec 22 17:52:23 1992                          */
#*    Last change :  Thu Jun 17 10:43:55 1993  (serrano)               */
#*                                                                     */
#*    Le scrypt shell qui lance un bench ...                           */
#*---------------------------------------------------------------------*/

#*---------------------------------------------------------------------*/
#*    Les parametres des differents compilateurs                       */
#*---------------------------------------------------------------------*/
#* set bigloo    = "`cat ../distribution/SITE`/bin/bigloo1.3"  */
set bigloo    = /usr/local/bin/bigloo
set bflags    = "-unsafe -O2 -farithmetic -cc gcc +rm -s -w"

set scc       = "/usr/local/bin/scc"
set sflags    = "-On -Ob -Og -Ot -O -cc gcc"

set cc        = "`which gcc`"
set cflags    = -O

set t         = "`which t`"
set tflags    = ""

set camll     = "`which camlc`"
set mflags    = ""

set camlot    = /home/cornas/icsla/cridlig/Camlot/camlot
set oflags    = "-f -O fast -cc gcc -ccopt -O"

set trun      = /home/cornas/icsla/serrano/prgm/project/bigloo/public/trun
set tcomp     = /home/cornas/icsla/serrano/prgm/project/bigloo/public/tcomp
set tflags    = ""

set wc        = "`which wc`"
set wflags    = ""

set bench     = $1 
set log       = "$bench/LOG"

set lex       = "`which lex`"
set lflags    = -t

set flex      = "`which flex`"
set fflags    = "-f -t"

set complice  = /home/cornas/icsla/serrano/prgm/project/bigloo/public/llcomp
set llflags   = ""

set repeat    = 10

echo "- $bench "
echo "--------------------------------------------------------------------" >! $log
echo "                     --o-O- $bench -O-o--" >> $log
echo "--------------------------------------------------------------------" >> $log

if (-f /usr/bin/time) then
	set timer = /usr/bin/time
else
	set timer = /bin/time
endif	

set ptimer = misc/parse-time
set psize  = misc/parse-size

#*---------------------------------------------------------------------*/
#*    bigloo                                                           */
#*---------------------------------------------------------------------*/
if( (-f "$bigloo") && (-d "$bench/bigloo") ) then
	echo "    [bigloo]"
	echo "`basename $bigloo` ($bflags):" >> $log
	echo "compile: " `$timer $bigloo $bflags $bench/bigloo/$bench.scm -o $bench/bigloo/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/bigloo/a.out $repeat |& $ptimer` >> & $log
	strip $bench/bigloo/a.out >& /dev/null
	echo "size   : " `ls -s $bench/bigloo/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    bigloo-nil                                                       */
#*---------------------------------------------------------------------*/
if( -f "$bigloo" && -d "$bench/bigloo-nil" ) then
	echo "    [bigloo]"
	echo "`basename $bigloo` ($bflags -nil):" >> $log
	echo "compile: " `$timer $bigloo $bflags -nil $bench/bigloo-nil/$bench.scm -o $bench/bigloo-nil/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/bigloo-nil/a.out $repeat |& $ptimer` >> & $log
	strip $bench/bigloo-nil/a.out >& /dev/null
	echo "size   : " `ls -s $bench/bigloo-nil/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    scc                                                              */
#*---------------------------------------------------------------------*/
if( -f "$scc" && -d "$bench/scc" ) then
	echo "    [scc]"
	echo "`basename $scc` ($sflags):" >> $log
	echo "compile: " `$timer $scc $sflags $bench/scc/$bench.sc -o $bench/scc/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/scc/a.out $repeat |& $ptimer` >> & $log
	strip $bench/scc/a.out >& /dev/null
	echo "size   : " `ls -s $bench/scc/a.out | $psize` >>& $log
	\rm -f $bench/scc/$bench.c
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    t                                                                */
#*---------------------------------------------------------------------*/
if( -f "$t" && -d "$bench/t" ) then
	echo "    [t]"
	echo "`basename $t` ($tflags):" >> $log
	echo "compile: " `$timer $tcomp $bench/t/$bench.t |& $ptimer` >> & $log
	echo "run    : " `$timer $trun $bench/t/$bench.t $repeat |& $ptimer` >> & $log
	strip  $bench/t/$bench.so >& /dev/null
	echo "size   : " `ls -s $bench/t/$bench.so | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    complice                                                         */
#*---------------------------------------------------------------------*/
if( -f "$complice" && -d "$bench/lelisp" ) then
	echo "    [complice]"
	echo "`basename $complice` ($llflags):" >> $log
	$complice $bench/lelisp/$bench.ll > /dev/null
	echo "run    : " `$timer $bench/lelisp/a.out |& $ptimer` >> & $log
	echo "" >> $log
	\rm $bench/lelisp/a.out $bench/lelisp/*.core
endif

#*---------------------------------------------------------------------*/
#*    camll                                                            */
#*---------------------------------------------------------------------*/
if( -f "$camll" && -d "$bench/camll" ) then
	echo "    [camll]"
	echo "`basename $camll` ($mflags)" >> $log
	echo "compile: " `$timer $camll $mflags $bench/camll/$bench.ml -o $bench/camll/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/camll/a.out $repeat |& $ptimer` >> & $log
	strip $bench/camll/a.out >& /dev/null
	echo "size   : " `ls -s $bench/camll/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    camlot                                                           */
#*---------------------------------------------------------------------*/
if( -f "$camlot" && -d "$bench/camlot" ) then
	echo "    [camlot]"
	echo "`basename $camlot` ($oflags)" >> $log
	echo "compile: " `$timer $camlot $oflags $bench/camlot/$bench.ml -o $bench/camlot/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/camlot/a.out $repeat |& $ptimer` >> & $log
	strip $bench/camlot/a.out >& /dev/null
	echo "size   : " `ls -s $bench/camlot/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    flex                                                             */
#*---------------------------------------------------------------------*/
if( -f "$flex" && -d "$bench/flex" ) then
	echo "    [flex]"
	echo "`basename $flex` ($fflags) : " >> $log
	echo "compile: " `$timer csh -c "$flex $fflags $bench/flex/$bench.flex >! $bench/flex/lex.yy.c; $cc $cflags $bench/flex/lex.yy.c -o $bench/flex/a.out" |& $ptimer` >> $log
	echo "run    : " `$timer $bench/flex/a.out $repeat |& $ptimer` >> & $log
	strip $bench/flex/a.out $repeat >& /dev/null
	\rm -f $bench/flex/lex.yy.c
	echo "size   : " `ls -s $bench/flex/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    lex                                                              */
#*---------------------------------------------------------------------*/
if( -f "$lex" && -d "$bench/lex" ) then
	echo "    [lex]"
	echo "`basename $lex` ($lflags) : " >> $log
	echo "compile: " `$timer csh -c "$lex $lflags $bench/lex/$bench.lex >! $bench/lex/lex.yy.c ; $cc $cflags $bench/lex/lex.yy.c -o $bench/lex/a.out" |& $ptimer` >> $log
	echo "run    : " `$timer $bench/lex/a.out $repeat |& $ptimer` >> & $log
	strip $bench/lex/a.out $repeat >& /dev/null
	\rm -f $bench/lex/lex.yy.c
	echo "size   : " `ls -s $bench/lex/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    cc                                                               */
#*---------------------------------------------------------------------*/
if( -f "$cc" && -d "$bench/cc" ) then
	echo "    [cc]"
	echo "`basename $cc` ($cflags)" >> $log
	echo "compile: " `$timer $cc $cflags $bench/cc/$bench.c -o $bench/cc/a.out |& $ptimer` >> & $log
	echo "run    : " `$timer $bench/cc/a.out $repeat |& $ptimer` >> & $log
	strip $bench/cc/a.out >& /dev/null
	echo "size   : " `ls -s $bench/cc/a.out | $psize` >>& $log
	echo "" >> $log
endif

#*---------------------------------------------------------------------*/
#*    wc                                                               */
#*---------------------------------------------------------------------*/
if( -f "$wc" && -d "$bench/wc" ) then
	echo "    [wc]"
	echo "`basename $wc` ($wflags)" >> $log
	echo "run    : " `$timer csh -c "$wc $bench/txt/$bench.txt >/dev/null; echo OK" |& $ptimer` >> & $log
	echo "" >> $log
endif
