From 007298b4d3a6997b77333cb780d2c114e6a95479 Mon Sep 17 00:00:00 2001 From: Jason Nochlin <91577+hundredwatt@users.noreply.github.com> Date: Thu, 11 Jan 2024 01:25:58 -0700 Subject: [PATCH] evaluate2.sh: Add Time Limit for Runs (#293) * evaluate2.sh: Add Time Limit for Runs * check that bc is installed --------- Co-authored-by: Jason Nochlin --- evaluate2.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/evaluate2.sh b/evaluate2.sh index 3ef14d0..a9e0339 100755 --- a/evaluate2.sh +++ b/evaluate2.sh @@ -34,6 +34,7 @@ BOLD_YELLOW='\033[1;33m' RESET='\033[0m' # No Color DEFAULT_JAVA_VERSION="21.0.1-open" +RUN_TIME_LIMIT=300 # seconds function check_command_installed { if ! [ -x "$(command -v $1)" ]; then @@ -45,6 +46,7 @@ function check_command_installed { check_command_installed java check_command_installed hyperfine check_command_installed jq +check_command_installed bc # Validate that ./calculate_average_.sh exists for each fork for fork in "$@"; do @@ -142,9 +144,13 @@ for fork in "$@"; do # Linux platform # prepend this with numactl --physcpubind=0-7 for running it only with 8 cores - numactl --physcpubind=0-7 hyperfine $HYPERFINE_OPTS "./calculate_average_$fork.sh 2>&1" - else - hyperfine $HYPERFINE_OPTS "./calculate_average_$fork.sh 2>&1" + numactl --physcpubind=0-7 hyperfine $HYPERFINE_OPTS "timeout -v $RUN_TIME_LIMIT ./calculate_average_$fork.sh 2>&1" + else # MacOS + timeout="" + if [ -x "$(command -v gtimeout)" ]; then + timeout="gtimeout -v $RUN_TIME_LIMIT" # from `brew install coreutils` + fi + hyperfine $HYPERFINE_OPTS "$timeout ./calculate_average_$fork.sh 2>&1" fi # Catch hyperfine command failed if [ $? -ne 0 ]; then