jsonschema-rs/perf-helpers/run

32 lines
797 B
Bash
Executable File

#!/bin/sh
set -euo pipefail
CURDIR=$(pwd)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ $# -lt 2 ]; then
echo "Usage: $0 <schema path> <instance path> [<number of iterations>]" > /dev/stderr
exit 1
fi
export SCHEMA_PATH="$(realpath $1)"
export INSTANCE_PATH="$(realpath $2)"
export NUMBER_OF_ITERATIONS="${3:-1234}"
# Ensure that flamegraph is installed
cargo flamegraph -h > /dev/null || cargo install flamegraph
# Clear files before starting
rm -rf trace.svg
# Move into perf-helpers package
pushd ${DIR}
# Ensure that a new build is re-issued as the content of the
# files and/or CLI arguments (env variables) might change
cargo clean --release --package perf_helpers
cargo flamegraph --root --output ${CURDIR}/trace.svg
# Exits perf-helpers
popd