aboutsummaryrefslogtreecommitdiff
path: root/tests/bench/bench.sh
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 21:33:50 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 21:33:50 +0330
commite67671d834f33e1a70f913f0c61f9d0c36292aa8 (patch)
tree5937e57622c9cb0a406bbc727c140b9778105cc5 /tests/bench/bench.sh
parentbench: matmul fill a = i % 7 - 2, b = i % 5 - 1 so its checksum is 63760 (che... (diff)
bench: a trap (zy exit 2) is labelled runtime trap with the stdout tail, since zy reports traps on stdout, in suite.py and bench.sh
Diffstat (limited to 'tests/bench/bench.sh')
-rw-r--r--tests/bench/bench.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/bench/bench.sh b/tests/bench/bench.sh
index 4032aa0..68232c6 100644
--- a/tests/bench/bench.sh
+++ b/tests/bench/bench.sh
@@ -24,13 +24,14 @@ if command -v aarch64-linux-gnu-gcc >/dev/null && command -v qemu-aarch64 >/dev/
fi
# seconds per run of kernel $2 on vm $1: the slope between $3 runs and 1 run,
# best of three each, so starting up and compiling cancel out
-# a nonzero zy exit (1 compile error, 2 trap) fails the whole bench, with the stderr tail
+# a nonzero zy exit (1 compile error, 2 runtime trap) fails the whole bench, with the tail of
+# stderr and stdout (zy reports a trap on stdout)
t(){
local s e c err=$(mktemp); s=$(date +%s.%N)
- (cat tests/programs/bench.zc; printf '`%s%s' $2 $3) | $1 >/dev/null 2>$err; c=$?
+ (cat tests/programs/bench.zc; printf '`%s%s' $2 $3) | $1 >$err.out 2>$err; c=$?
e=$(date +%s.%N)
- if [ $c != 0 ]; then echo "bench.sh: tests/programs/bench.zc kernel $2 ($3 reps) on $1: zy exited $c; stderr tail:" >&2; tail -n 8 $err >&2; rm -f $err; return 1; fi
- rm -f $err; echo "$e - $s" | bc
+ if [ $c != 0 ]; then echo "bench.sh: tests/programs/bench.zc kernel $2 ($3 reps) on $1: zy exited $c ($([ $c = 2 ] && echo runtime trap || { [ $c = 1 ] && echo compile error || echo failed; })); stderr and stdout tail:" >&2; tail -n 8 $err $err.out >&2; rm -f $err $err.out; return 1; fi
+ rm -f $err $err.out; echo "$e - $s" | bc
}
best(){ local b=999 x i; for i in 1 2 3; do x=$(t "$1" $2 $3) || return 1; b=$(echo "if ($x < $b) $x else $b" | bc); done; echo $b; }
# grows the run count until the difference is at least a second, so the noise