This repository has been archived by the owner on Apr 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunit
executable file
·137 lines (124 loc) · 2.81 KB
/
runit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/ksh
#
# Usage: speed [options] [benchmarks]
#
#set -x
CMD=$0
SML=${SML:=/usr/local/bin/sml}
SRC=`pwd`
NRUNS=6
OUT_FILE=LOG
ALLOC=512k
FP_TESTS="simple mandelbrot ray barnes-hut"
ALL_TESTS="boyer life knuth-bendix lexgen mlyacc vliw $FP_TESTS"
NEW_TESTS="fft logic tsp"
ALL_TESTS="$ALL_TESTS $NEW_TESTS"
#
# process arguments
#
while [ "$#" != "0" ]
do
arg=$1; shift
case $arg in
-sml)
if [ "$#" = "0" ]; then
echo "$CMD must supply argument for -sml option"
exit 1
fi
SML=$1; shift
;;
-out)
if [ "$#" = "0" ]; then
echo "$CMD must supply file name with -out option"
exit 1
fi
OUT_FILE=$1; shift
;;
-alloc)
if [ "$#" = "0" ]; then
echo "$CMD must supply allocation size with -alloc option"
exit 1
fi
ALLOC=$1; shift
;;
*)
echo "$CMD Usage: runit [-sml <sml-path>] [-out <file>] [-alloc <size>]"
exit 1
;;
esac
done
SML="$SML @SMLalloc=$ALLOC"
echo Using $SML ...
#
# run the tests
#
/bin/rm -rf programs/CM
echo "[" >> $OUT_FILE
for prog in $ALL_TESTS; do
if [[ $prog = "knuth-bendix" ]]
then
name=knuthBendix
elif [[ $prog = "barnes-hut" ]]
then
name=barnesHut
else
name=$prog
fi
echo $name
#
# measure interactive compile time
#
echo " compiling ..."
echo "{Bmark=\"$name\"," >> $OUT_FILE
$SML <<EOF 1>/dev/null 2>&1
use "programs/timeit.sml";
val outstrm = TextIO.openAppend("$OUT_FILE");
fun compileIt (n, outstrm, fname) = let
fun loop 0 = ()
| loop i = let
val t0 = Timing.start()
in
use fname;
Timing.output(outstrm, Timing.stop t0);
TextIO.output(outstrm, if i>1 then ",\n" else "\n");
TextIO.flushOut outstrm;
loop (i-1)
end
in
TextIO.output(outstrm, " Compiles=[\n");
TextIO.output(TextIO.stdOut, "in compileIt\n");
loop n;
TextIO.output(outstrm, "\t],\n")
end;
Compiler.Control.MC.matchRedundantError := false;
OS.FileSys.chDir "programs/$prog";
compileIt(1, outstrm, "load");
TextIO.flushOut outstrm;
TextIO.closeOut outstrm;
EOF
#
# measure execution time
#
echo " running ..."
/bin/rm -rf programs/$prog/CM
$SML <<EOF 1>/dev/null 2>&1
Compiler.Control.MC.matchRedundantError := false;
OS.FileSys.chDir "programs/$prog";
CM.make();
EOF
#
# run it.
#
$SML <<EOF 1>/dev/null 2>&1
val outstrm = TextIO.openAppend("$OUT_FILE");
OS.FileSys.chDir "programs/$prog";
CM.make();
Timing.time($NRUNS, outstrm, Main.doit);
TextIO.output(outstrm, "};\n");
TextIO.output(outstrm, "\n"); TextIO.flushOut outstrm;
TextIO.closeOut outstrm;
EOF
/bin/rm -rf programs/$prog/CM
done
echo "{Bmark=\"$OUT_FILE\", Compiles=[], Runs=[]}]" >> $OUT_FILE
/bin/rm -rf programs/CM