| 1 | #!/usr/bin/env sh |
| 2 | set -eu |
| 3 | |
| 4 | script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd) |
| 5 | repo_root=$(CDPATH= cd "$script_dir/../../../.." && pwd) |
| 6 | cd "$repo_root" |
| 7 | |
| 8 | if [ ! -x ./v ]; then |
| 9 | echo "x.async benchmarks must be run from a V checkout with local ./v" >&2 |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | tmp_root=$(mktemp -d "${TMPDIR:-/tmp}/xasync-benchmark.XXXXXX") |
| 14 | cleanup() { |
| 15 | rm -rf "$tmp_root" |
| 16 | } |
| 17 | trap cleanup EXIT INT TERM |
| 18 | |
| 19 | vtmp="$tmp_root/vtmp" |
| 20 | vcache="$tmp_root/vcache" |
| 21 | out="$tmp_root/out/async_benchmark" |
| 22 | mkdir -p "$vtmp" "$vcache" "$(dirname "$out")" |
| 23 | |
| 24 | echo "Running x.async benchmark with isolated VTMP and VCACHE." |
| 25 | echo "Tune sizes with XASYNC_BENCH_GROUP_ROUNDS, XASYNC_BENCH_GROUP_JOBS," |
| 26 | echo "XASYNC_BENCH_TASK_ROUNDS, XASYNC_BENCH_POOL_JOBS," |
| 27 | echo "XASYNC_BENCH_POOL_WORKERS, XASYNC_BENCH_TIMEOUT_ROUNDS," |
| 28 | echo "XASYNC_BENCH_EVERY_ITERATIONS, and XASYNC_BENCH_EVERY_INTERVAL_MS." |
| 29 | |
| 30 | if command -v timeout >/dev/null 2>&1; then |
| 31 | timeout 180s env VTMP="$vtmp" VCACHE="$vcache" ./v -prod -o "$out" run vlib/x/async/benchmarks/async_benchmark.v |
| 32 | else |
| 33 | env VTMP="$vtmp" VCACHE="$vcache" ./v -prod -o "$out" run vlib/x/async/benchmarks/async_benchmark.v |
| 34 | fi |
| 35 | |