mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 15:53:29 +01:00
Add option to specify bat target in run-benchmarks.sh
This commit is contained in:
parent
7a180e22ff
commit
e3bc41dbe6
32
tests/benchmarks/run-benchmarks.sh
vendored
32
tests/benchmarks/run-benchmarks.sh
vendored
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
if ! which hyperfine > /dev/null 2>&1; then
|
||||
@ -8,21 +7,46 @@ if ! which hyperfine > /dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BAT=''
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--system) BAT="bat" ;;
|
||||
--debug) BAT="../../target/debug/bat" ;;
|
||||
--release) BAT="../../target/release/bat" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$BAT" ]]; then
|
||||
echo "A build of 'bat' must be specified for benchmarking."
|
||||
echo "You can use '--system', '--debug', or '--release'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v "$BAT" &>/dev/null; then
|
||||
echo "Could not find the build of bat to benchmark."
|
||||
case "$BAT" in
|
||||
"bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
|
||||
"../../target/debug/debug") echo "Make you sure to 'cargo build' first." ;;
|
||||
"../../target/debug/release") echo "Make you sure to 'cargo build --release' first." ;;
|
||||
esac
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "### Startup time"
|
||||
echo
|
||||
|
||||
hyperfine --warmup 3 bat
|
||||
hyperfine --warmup 3 "$BAT"
|
||||
|
||||
echo
|
||||
echo "### Plain text"
|
||||
echo
|
||||
|
||||
hyperfine --warmup 3 "bat --language txt --paging=never 'test-src/jquery-3.3.1.js'"
|
||||
hyperfine --warmup 3 "$(printf "%q" "$BAT") --language txt --paging=never 'test-src/jquery-3.3.1.js'"
|
||||
|
||||
echo
|
||||
echo "### Time to syntax-highlight large files"
|
||||
echo
|
||||
|
||||
for SRC in test-src/*; do
|
||||
hyperfine --warmup 3 "bat --style=full --color=always --paging=never '$SRC'"
|
||||
hyperfine --warmup 3 "$(printf "%q" "$BAT") --style=full --color=always --paging=never $(printf "%q" "$SRC")"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user