aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Nochlin <91577+hundredwatt@users.noreply.github.com>2024-01-11 01:25:58 -0700
committerGitHub <noreply@github.com>2024-01-11 09:25:58 +0100
commit007298b4d3a6997b77333cb780d2c114e6a95479 (patch)
tree37001ee89ddc43a112075182b3a9d5a26461af7b
parente084c367606cf164f96f0c6dae7f7ec8dc179a96 (diff)
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>
-rwxr-xr-xevaluate2.sh12
1 files 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_<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