-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathb
More file actions
executable file
·72 lines (65 loc) · 2.22 KB
/
b
File metadata and controls
executable file
·72 lines (65 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -e
print_usage() {
echo "Usage: $0 <command> <bench>"
echo "command: bench, micro, perf, time, valgrind"
echo "bench: Name or partial name of the benchmark to run"
}
COMMAND=$1
BENCH=$2
if [ -z "$COMMAND" ]; then
print_usage
exit 1
fi
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ARIA_BUILD_CONFIG="${ARIA_BUILD_CONFIG:-release}"
CPU_AFFINITY_MASK="${CPU_AFFINITY_MASK:-0x1}"
if [ -z "${ARIA_EXECUTABLE:-}" ]; then
cargo build --profile "$ARIA_BUILD_CONFIG" --bin aria
TARGET_DIR=$(cd "$SELF_DIR" && cargo metadata --format-version 1 --no-deps 2>/dev/null | jq -r '.target_directory // empty' 2>/dev/null || true)
if [ -z "$TARGET_DIR" ]; then
TARGET_DIR="${SELF_DIR}/../target"
fi
ARIA_EXECUTABLE="${TARGET_DIR}/${ARIA_BUILD_CONFIG}/aria"
fi
export ARIA_EXECUTABLE
ARIA_LIB_DIR="${ARIA_LIB_DIR:-${SELF_DIR}/lib:${SELF_DIR}/lib-test}"
export ARIA_LIB_DIR="$ARIA_LIB_DIR"
if [ "$COMMAND" = "bench" ]; then
cargo bench --profile "$ARIA_BUILD_CONFIG" --package vm-lib "$BENCH"
elif [ "$COMMAND" = "micro" ]; then
if [ ! -f "$BENCH" ]; then
BENCH="${SELF_DIR}/microbenchmarks/${BENCH}.aria"
fi
ARIA_LIB_DIR="${ARIA_LIB_DIR}:${SELF_DIR}/microbenchmarks"
export ARIA_LIB_DIR
if command -v taskset >/dev/null 2>&1; then
exec taskset "$CPU_AFFINITY_MASK" "${ARIA_EXECUTABLE}" "$BENCH" "${@:3}"
else
exec "${ARIA_EXECUTABLE}" "$BENCH" "${@:3}"
fi
else
OUTPUT=$(cargo bench --no-run --profile "$ARIA_BUILD_CONFIG" --package vm-lib "$BENCH" 2>&1)
echo "$OUTPUT"
EXECUTABLE_PATH=$(echo "$OUTPUT" | grep "^ Executable" | tail -n1 | awk '{gsub(/[()]/,"",$NF); print $NF}')
case "$COMMAND" in
perf)
echo "Running with perf..."
perf record -g "$EXECUTABLE_PATH" "$BENCH"
;;
valgrind)
echo "Running with Valgrind Callgrind..."
ulimit -n 4096
valgrind --tool=callgrind "$EXECUTABLE_PATH" "$BENCH"
;;
time)
echo "Running with time..."
time "$EXECUTABLE_PATH" "$BENCH"
;;
*)
echo "Invalid command"
print_usage
exit 1
;;
esac
fi