2020-10-04 09:37:37 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-10-04 10:07:22 +00:00
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
|
2018-05-14 19:42:07 +00:00
|
|
|
if ! which hyperfine > /dev/null 2>&1; then
|
|
|
|
echo "'hyperfine' does not seem to be installed."
|
|
|
|
echo "You can get it here: https://github.com/sharkdp/hyperfine"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-10-05 22:28:23 +00:00
|
|
|
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
|
|
|
|
|
2018-05-14 19:42:07 +00:00
|
|
|
echo "### Startup time"
|
|
|
|
echo
|
|
|
|
|
2020-10-05 22:28:23 +00:00
|
|
|
hyperfine --warmup 3 "$BAT"
|
2018-05-14 19:42:07 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "### Plain text"
|
|
|
|
echo
|
|
|
|
|
2020-10-05 22:28:23 +00:00
|
|
|
hyperfine --warmup 3 "$(printf "%q" "$BAT") --language txt --paging=never 'test-src/jquery-3.3.1.js'"
|
2018-05-14 19:42:07 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "### Time to syntax-highlight large files"
|
|
|
|
echo
|
|
|
|
|
|
|
|
for SRC in test-src/*; do
|
2020-10-05 22:28:23 +00:00
|
|
|
hyperfine --warmup 3 "$(printf "%q" "$BAT") --style=full --color=always --paging=never $(printf "%q" "$SRC")"
|
2018-05-14 19:42:07 +00:00
|
|
|
done
|