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