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 <hundredwatt@users.noreply.github.com>
This commit is contained in:
Jason Nochlin 2024-01-11 01:25:58 -07:00 committed by GitHub
parent e084c36760
commit 007298b4d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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_<fork>.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