source: doc/theses/andrew_beach_MMath/code/test.sh @ 1a9592a

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since 1a9592a was 140eb16, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Andrew MMath: Updated the performance numbers for hopefully the last time.

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