vq / vlib / x / async / benchmarks / run_async_benchmark.sh
32 lines · 26 sloc · 976 bytes · a66aa5b0fe618b32988f4fd9b235017c336940ba
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_* environment variables."
26echo "See vlib/x/async/benchmarks/README.md for the full list."
27
28if command -v timeout >/dev/null 2>&1; then
29 timeout 180s env VTMP="$vtmp" VCACHE="$vcache" ./v -prod -o "$out" run vlib/x/async/benchmarks/async_benchmark.v
30else
31 env VTMP="$vtmp" VCACHE="$vcache" ./v -prod -o "$out" run vlib/x/async/benchmarks/async_benchmark.v
32fi
33