Limit running time to given wall-clock seconds; remove the forcibly termination by the CPU time limit

master
Ivan Zahariev 2016-09-08 18:02:31 +03:00
parent f65af29797
commit c2f533f376
1 changed files with 5 additions and 8 deletions

13
run.sh
View File

@ -8,8 +8,11 @@ MIN_NLINES="${MIN_NLINES:=10}" # it's a fatal error if we get less than this num
SRC_FILTER="${SRC_FILTER:=x}" # execute only given tests
DRY_RUN="${DRY_RUN:=0}"
echo "# Run time limited to $RUN_TIME CPU seconds"
export RUN_TIME
echo "# Run time limited to $RUN_TIME wall-clock seconds"
echo "#"
# Note: This increases the memory usage but should still provide linear performance.
function run_benchmark() {
HEADER="$1"
@ -47,17 +50,11 @@ function run_benchmark() {
TIMES_FILE="$(mktemp --suffix .langs_perf)" || exit 1
# Limit the total CPU time by using "ulimit".
# Note: This increases the memory usage but should still provide linear performance.
# Force unbuffered output by using "stdbuf" or else we lose the output on SIGKILL.
OUT="$(
{
ulimit -t "$RUN_TIME" || exit 1
/usr/bin/time -o "$TIMES_FILE" --format \
'real_TIME:%esec user_CPU:%Usec sys_CPU:%Ssec max_RSS:%Mkb swaps:%W ctx_sw:%c+%w' \
stdbuf -o0 -e0 $RUN_CMD
$RUN_CMD
} 2>&1
)"