2023-08-21 05:26:52 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2023-09-29 15:19:50 +00:00
|
|
|
: ${PROFILE:="perf"}
|
2023-08-21 05:26:52 +00:00
|
|
|
|
2023-09-29 15:19:50 +00:00
|
|
|
function main {
|
|
|
|
local additional_flags=()
|
|
|
|
if [ "$PROFILE" = "dev" ] || [ "$PROFILE" = "debug" ]; then
|
|
|
|
PROFILE="debug"
|
|
|
|
else
|
|
|
|
additional_flags+=(--profile "$PROFILE")
|
|
|
|
# We have to disable avx512 because valgrind does not yet support it.
|
|
|
|
export RUSTFLAGS="-C target-feature=-avx512"
|
|
|
|
fi
|
2023-09-09 01:50:32 +00:00
|
|
|
|
2023-09-29 15:19:50 +00:00
|
|
|
(cd "$DIR/../" && RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --no-default-features "${additional_flags[@]}")
|
|
|
|
valgrind --tool=callgrind --callgrind-out-file="$DIR/../callgrind.out" "$DIR/../target/${PROFILE}/parse" "${@}"
|
2023-08-21 05:26:52 +00:00
|
|
|
|
2023-09-29 15:19:50 +00:00
|
|
|
echo "You probably want to run:"
|
|
|
|
echo "callgrind_annotate --auto=yes '$DIR/../callgrind.out'"
|
|
|
|
}
|
|
|
|
|
|
|
|
main "${@}"
|