forked from arialang/aria
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb
More file actions
executable file
·51 lines (44 loc) · 1.36 KB
/
Copy pathb
File metadata and controls
executable file
·51 lines (44 loc) · 1.36 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
#!/usr/bin/env bash
set -e
print_usage() {
echo "Usage: $0 <command> <bench>"
echo "command: bench, perf, valgrind, time"
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}"
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"
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