mirror of
https://github.com/sharkdp/bat.git
synced 2025-06-21 18:11:27 +02:00
Improve benchmark script to support cargo/config target-dir
This commit is contained in:
parent
e26ec31463
commit
3ed0081f1f
31
tests/benchmarks/run-benchmarks.sh
vendored
31
tests/benchmarks/run-benchmarks.sh
vendored
@ -1,18 +1,35 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
# Check that Hyperfine is installed.
|
||||||
if ! which hyperfine > /dev/null 2>&1; then
|
if ! which hyperfine > /dev/null 2>&1; then
|
||||||
echo "'hyperfine' does not seem to be installed."
|
echo "'hyperfine' does not seem to be installed." 1>&2
|
||||||
echo "You can get it here: https://github.com/sharkdp/hyperfine"
|
echo "You can get it here: https://github.com/sharkdp/hyperfine" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Determine the target directories.
|
||||||
|
get_target_dir() {
|
||||||
|
if [[ -f "$HOME/.cargo/config" ]]; then
|
||||||
|
grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
|
||||||
|
| sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
|
||||||
|
&& return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "../../target"
|
||||||
|
}
|
||||||
|
|
||||||
|
TARGET_DIR="$(get_target_dir)"
|
||||||
|
TARGET_DEBUG="${TARGET_DIR}/debug/bat"
|
||||||
|
TARGET_RELEASE="${TARGET_DIR}/release/bat"
|
||||||
|
|
||||||
|
# Determine which target to benchmark.
|
||||||
BAT=''
|
BAT=''
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--system) BAT="bat" ;;
|
--system) BAT="bat" ;;
|
||||||
--debug) BAT="../../target/debug/bat" ;;
|
--debug) BAT="$TARGET_DEBUG" ;;
|
||||||
--release) BAT="../../target/release/bat" ;;
|
--release) BAT="$TARGET_RELEASE" ;;
|
||||||
--bat=*) BAT="${arg:6}" ;;
|
--bat=*) BAT="${arg:6}" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -23,16 +40,18 @@ if [[ -z "$BAT" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure that the target is built.
|
||||||
if ! command -v "$BAT" &>/dev/null; then
|
if ! command -v "$BAT" &>/dev/null; then
|
||||||
echo "Could not find the build of bat to benchmark."
|
echo "Could not find the build of bat to benchmark."
|
||||||
case "$BAT" in
|
case "$BAT" in
|
||||||
"bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
|
"bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
|
||||||
"../../target/debug/debug") echo "Make you sure to 'cargo build' first." ;;
|
"$TARGET_DEBUG") echo "Make you sure to 'cargo build' first." ;;
|
||||||
"../../target/debug/release") echo "Make you sure to 'cargo build --release' first." ;;
|
"$TARGET_RELEASE") echo "Make you sure to 'cargo build --release' first." ;;
|
||||||
esac
|
esac
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run the benchmark.
|
||||||
echo "### Startup time"
|
echo "### Startup time"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user