diff --git a/runtime/experiments/applications/ocr/handwriting/.gitignore b/runtime/experiments/applications/ocr/handwriting/.gitignore new file mode 100644 index 0000000..aaf36ac --- /dev/null +++ b/runtime/experiments/applications/ocr/handwriting/.gitignore @@ -0,0 +1 @@ +res/* diff --git a/runtime/experiments/applications/ocr/handwriting/debug.sh b/runtime/experiments/applications/ocr/handwriting/debug.sh deleted file mode 100755 index 879d485..0000000 --- a/runtime/experiments/applications/ocr/handwriting/debug.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Executes the runtime in GDB -# Substitutes the absolute path from the container with a path relatively derived from the location of this script -# This allows debugging outside of the Docker container -# Also disables pagination and stopping on SIGUSR1 - -experiment_directory=$(pwd) -project_directory=$(cd ../../../.. && pwd) -binary_directory=$(cd "$project_directory"/bin && pwd) - -export LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" -export PATH="$binary_directory:$PATH" - -gdb --eval-command="handle SIGUSR1 nostop" \ - --eval-command="handle SIGPIPE nostop" \ - --eval-command="set pagination off" \ - --eval-command="set substitute-path /sledge/runtime $project_directory" \ - --eval-command="run $experiment_directory/spec.json" \ - sledgert diff --git a/runtime/experiments/applications/ocr/handwriting/edf_nopreemption.env b/runtime/experiments/applications/ocr/handwriting/edf_nopreemption.env new file mode 100644 index 0000000..ff31501 --- /dev/null +++ b/runtime/experiments/applications/ocr/handwriting/edf_nopreemption.env @@ -0,0 +1,3 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=true +SLEDGE_NWORKERS=1 diff --git a/runtime/experiments/applications/ocr/handwriting/edf_preemption.env b/runtime/experiments/applications/ocr/handwriting/edf_preemption.env new file mode 100644 index 0000000..b5da0db --- /dev/null +++ b/runtime/experiments/applications/ocr/handwriting/edf_preemption.env @@ -0,0 +1,4 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=false +SLEDGE_SIGALRM_HANDLER=TRIAGED +SLEDGE_NWORKERS=1 diff --git a/runtime/experiments/applications/ocr/handwriting/fifo_nopreemption.env b/runtime/experiments/applications/ocr/handwriting/fifo_nopreemption.env new file mode 100644 index 0000000..d043589 --- /dev/null +++ b/runtime/experiments/applications/ocr/handwriting/fifo_nopreemption.env @@ -0,0 +1,3 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=true +SLEDGE_NWORKERS=1 diff --git a/runtime/experiments/applications/ocr/handwriting/fifo_preemption.env b/runtime/experiments/applications/ocr/handwriting/fifo_preemption.env new file mode 100644 index 0000000..74ced18 --- /dev/null +++ b/runtime/experiments/applications/ocr/handwriting/fifo_preemption.env @@ -0,0 +1,3 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=false +SLEDGE_NWORKERS=1 diff --git a/runtime/experiments/applications/ocr/handwriting/run.sh b/runtime/experiments/applications/ocr/handwriting/run.sh index fefe210..e3c05fa 100755 --- a/runtime/experiments/applications/ocr/handwriting/run.sh +++ b/runtime/experiments/applications/ocr/handwriting/run.sh @@ -1,72 +1,62 @@ #!/bin/bash -# Executes the runtime in GDB -# Substitutes the absolute path from the container with a path relatively derived from the location of this script -# This allows debugging outside of the Docker container -# Also disables pagination and stopping on SIGUSR1 -experiment_directory=$(pwd) -echo "$experiment_directory" -project_directory=$(cd ../../../.. && pwd) -binary_directory=$(cd "$project_directory"/bin && pwd) - -did_pass=true - -if [ "$1" != "-d" ]; then - PATH="$binary_directory:$PATH" LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" sledgert "$experiment_directory/spec.json" & - sleep 1 -else - echo "Running under gdb" -fi - -expected_result="$(cat ./expected_result.txt)" - -# Retry 5 times in case the runtime startup is slow -retries=5 -for ((i = 0; i < retries; i++)); do - result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary "@handwrt1.pnm" localhost:10000 2> /dev/null) - if [[ "$result" == "$expected_result" ]]; then - break - fi - - if ((i == 4)); then - echo "Retries exhaused" - exit 1 - fi - - sleep 1 -done - -success_count=0 -total_count=50 - -for ((i = 0; i < total_count; i++)); do - result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary "@handwrt1.pnm" localhost:10000 2> /dev/null) - # echo "$result" - if [[ "$result" == "$expected_result" ]]; then - success_count=$((success_count + 1)) +__run_sh__base_path="$(dirname "$(realpath --logical "${BASH_SOURCE[0]}")")" +__run_sh__bash_libraries_relative_path="../../../bash_libraries" +__run_sh__bash_libraries_absolute_path=$(cd "$__run_sh__base_path" && cd "$__run_sh__bash_libraries_relative_path" && pwd) +export PATH="$__run_sh__bash_libraries_absolute_path:$PATH" + +source csv_to_dat.sh || exit 1 +source framework.sh || exit 1 +source get_result_count.sh || exit 1 +source panic.sh || exit 1 +source path_join.sh || exit 1 + +# Validate that required tools are in path +declare -a required_binaries=(curl) +validate_dependencies() { + for required_binary in "${required_binaries[@]}"; do + if ! command -v "$required_binary" > /dev/null; then + echo "$required_binary is not present." >> "$results_directory/results.txt" + exit 1 + fi + done +} + +experiment_main() { + local -r hostname="$1" + local -r results_directory="$2" + + validate_dependencies + + local -r expected_result="$(cat ./expected_result.txt)" + + local -i success_count=0 + local -ir total_count=10 + + for ((i = 0; i < total_count; i++)); do + result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary "@handwrt1.pnm" "$hostname:10000" 2> /dev/null) + if [[ "$result" == "$expected_result" ]]; then + ((success_count++)) + else + { + echo "FAIL" + echo "Expected:" + echo "$expected_result" + echo "===============================================" + echo "Was:" + echo "$result" + } >> "$results_directory/results.txt" + break + fi + done + + echo "$success_count / $total_count" >> "$results_directory/results.txt" + + if ((success_count == total_count)); then + return 0 else - echo "FAIL" - echo "Expected:" - echo "$expected_result" - echo "===============================================" - echo "Was:" - echo "$result" - did_pass=false - break + return 1 fi -done - -echo "$success_count / $total_count" - -if [ "$1" != "-d" ]; then - sleep 5 - echo -n "Running Cleanup: " - pkill sledgert > /dev/null 2> /dev/null - echo "[DONE]" -fi +} -if $did_pass; then - exit 0 -else - exit 1 -fi +main "$@"