source: doc/theses/andrew_beach_MMath/code/test.sh @ f79ee0d

enumforall-pointer-decayjacob/cs343-translation
Last change on this file since f79ee0d was f79ee0d, checked in by Peter A. Buhr <pabuhr@…>, 10 months ago

update exception benchmarks

  • Property mode set to 100755
File size: 4.4 KB
Line 
1#!/usr/bin/env bash
2
3# Usage:
4# test.sh LANGUAGE TEST
5#   Run the TEST in LANGUAGE.
6# test.sh -a
7#   Build all tests.
8# test.sh -b SOURCE_FILE...
9#   Build a test from SOURCE_FILE(s).
10# test.sh -c
11#   Clean all executables.
12# test.sh -v LANGUAGE TEST FILE
13#   View the result from TEST in LANGUAGE stored in FILE.
14
15readonly ITERS_1M=1000000 # 1 000 000, one million
16readonly ITERS_10M=10000000 # 10 000 000, ten million
17readonly ITERS_100M=100000000 # 100 000 000, hundred million
18readonly ITERS_1000M=1000000000 # 1 000 000 000, billion
19readonly STACK_HEIGHT=100
20
21# Build Test Programs:
22# Mini-Make: TARGET SOURCE COMMAND ARGS...
23mmake() (
24        if [ ! -e "$1" -o "$1" -ot "$2" ]; then
25                "${@:3}"
26        fi
27)
28
29build() (
30        case "$1" in
31        *.cfa)
32                # Requires a symbolic link.
33                mmake "${1%.cfa}" "$1" cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
34                ;;
35        *.cpp)
36                mmake "${1%.cpp}-cpp" "$1" g++-10 -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
37                ;;
38        *.java)
39                mmake "${1%.java}.class" "$1" javac "$1"
40                ;;
41        *)
42                echo "Don't know how to build:" $1 >&2
43                exit 2
44                ;;
45        esac
46)
47
48if [ "-a" = "$1" ]; then                        # build all
49        for file in *.cfa *.cpp *.java; do
50                build $file
51        done
52        exit 0
53elif [ "-b" = "$1" ]; then                      # build given
54        for file in "${@:2}"; do
55                build $file
56        done
57        exit 0
58elif [ "-c" = "$1" ]; then                      # clean all
59        rm -f `basename -s ".cfa" -a *.cfa`
60        rm -f `basename -s ".cpp" -a *.cpp`
61        rm -f *-cpp
62        rm -f *.class
63        exit 0
64elif [ "-v" = "$1" -a 4 = "$#" ]; then
65        TEST_LANG="$2"
66        TEST_CASE="$3"
67        VIEW_FILE="$4"
68elif [ 2 -eq "$#" ]; then
69        TEST_LANG="$1"
70        TEST_CASE="$2"
71else
72        echo "Unknown call pattern." >&2
73        exit 2
74fi
75
76# Run Test Programs:
77# Used in place of unsupported language/test combinations.
78unsupported() {
79        echo "Run-Time: NA"
80}
81
82case "$TEST_CASE" in
83raise-empty)
84        CFAT="./throw-empty $ITERS_1M $STACK_HEIGHT"
85# see resume-fixup-empty-r      CFAR="./resume-empty $ITERS_1M $STACK_HEIGHT"
86        CPP="./throw-empty-cpp $ITERS_1M $STACK_HEIGHT"
87        JAVA="java ThrowEmpty $ITERS_1M $STACK_HEIGHT"
88        PYTHON="./throw-empty.py $ITERS_1M $STACK_HEIGHT"
89        ;;
90raise-detor)
91        CFAT="./throw-detor $ITERS_1M $STACK_HEIGHT"
92# N/A   CFAR="./resume-detor $ITERS_1M $STACK_HEIGHT"
93        CPP="./throw-detor-cpp $ITERS_1M $STACK_HEIGHT"
94        JAVA=unsupported
95        PYTHON=unsupported
96        ;;
97raise-finally)
98        CFAT="./throw-finally $ITERS_1M $STACK_HEIGHT"
99# N/A   CFAR="./resume-finally $ITERS_1M $STACK_HEIGHT"
100        CPP=unsupported
101        JAVA="java ThrowFinally $ITERS_1M $STACK_HEIGHT"
102        PYTHON="./throw-finally.py $ITERS_1M $STACK_HEIGHT"
103        ;;
104raise-other)
105        CFAT="./throw-other $ITERS_1M $STACK_HEIGHT"
106# N/A   CFAR="./resume-other $ITERS_1M $STACK_HEIGHT"
107        CPP="./throw-other-cpp $ITERS_1M $STACK_HEIGHT"
108        JAVA="java ThrowOther $ITERS_1M $STACK_HEIGHT"
109        PYTHON="./throw-other.py $ITERS_1M $STACK_HEIGHT"
110        ;;
111try-catch)
112        CFAT="./try-catch $ITERS_1000M"
113        CFAR="./try-resume $ITERS_1000M"
114        CPP="./try-catch-cpp $ITERS_1000M"
115        JAVA="java TryCatch $ITERS_1000M"
116        PYTHON="./try-catch.py $ITERS_1000M"
117        ;;
118try-finally)
119        CFAT="./try-finally $ITERS_1000M"
120        CFAR=unsupported
121        CPP=unsupported
122        JAVA="java TryFinally $ITERS_1000M"
123        PYTHON="./try-finally.py $ITERS_1000M"
124        ;;
125cond-match-all)
126        CFAT="./cond-catch $ITERS_10M 1"
127        CFAR="./cond-fixup $ITERS_10M 1"
128        CPP="./cond-catch-cpp $ITERS_10M 1"
129        JAVA="java CondCatch $ITERS_10M 1"
130        PYTHON="./cond-catch.py $ITERS_10M 1"
131        ;;
132cond-match-none)
133        CFAT="./cond-catch $ITERS_10M 0"
134        CFAR="./cond-fixup $ITERS_10M 0"
135        CPP="./cond-catch-cpp $ITERS_10M 0"
136        JAVA="java CondCatch $ITERS_10M 0"
137        PYTHON="./cond-catch.py $ITERS_10M 0"
138        ;;
139raise-fixup-empty)
140        CFAT="./resume-fixup-empty-f $ITERS_10M $STACK_HEIGHT"
141        CFAR="./resume-fixup-empty-r $ITERS_10M $STACK_HEIGHT"
142        CPP="./resume-fixup-empty-cpp $ITERS_10M $STACK_HEIGHT"
143        JAVA="java ResumeFixupEmpty $ITERS_10M $STACK_HEIGHT"
144        PYTHON="./resume-fixup-empty.py $ITERS_10M $STACK_HEIGHT"
145        ;;
146raise-fixup-other)
147        CFAT="./resume-fixup-other-f $ITERS_10M $STACK_HEIGHT"
148        CFAR="./resume-fixup-other-r $ITERS_10M $STACK_HEIGHT"
149        CPP="./resume-fixup-other-cpp $ITERS_10M $STACK_HEIGHT"
150        JAVA="java ResumeFixupOther $ITERS_10M $STACK_HEIGHT"
151        PYTHON="./resume-fixup-other.py $ITERS_10M $STACK_HEIGHT"
152        ;;
153*)
154        echo "No such test: $TEST_CASE" >&2
155        exit 2
156        ;;
157esac
158
159case "$TEST_LANG" in
160        cfa-t) CALL="$CFAT";;
161        cfa-r) CALL="$CFAR";;
162        cpp) CALL="$CPP";;
163        java) CALL="$JAVA";;
164        python) CALL="$PYTHON";;
165        *)
166                echo "No such language: $TEST_LANG" >&2
167                exit 2
168        ;;
169esac
170
171echo $CALL
172
173if [ -n "$VIEW_FILE" ]; then
174        grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'
175        exit
176fi
177
178$CALL
Note: See TracBrowser for help on using the repository browser.