on master help sign in
Add option to specify bat target in run-benchmarks.sh
commite3bc41dbe67c964c1d35ab1c127b28991ae19772 authorEthan P <eth-p+git@hidden.email> dateMon 5 Oct 2020, 15:28 (6 years ago) parent7a180e2
1 file changed+28−4
tests/benchmarks/run-benchmarks.sh+28−4
tests/benchmarks/run-benchmarks.sh+28−4
@@ -1,5 +1,4 @@
11#!/usr/bin/env bash
2−
32cd "$(dirname "${BASH_SOURCE[0]}")"
43
54if ! which hyperfine > /dev/null 2>&1; then
@@ -8,21 +7,46 @@ if ! which hyperfine > /dev/null 2>&1; then
87 exit 1
98fi
109
10+BAT=''
11+for arg in "$@"; do
12+ case "$arg" in
13+ --system) BAT="bat" ;;
14+ --debug) BAT="../../target/debug/bat" ;;
15+ --release) BAT="../../target/release/bat" ;;
16+ esac
17+done
18+
19+if [[ -z "$BAT" ]]; then
20+ echo "A build of 'bat' must be specified for benchmarking."
21+ echo "You can use '--system', '--debug', or '--release'."
22+ exit 1
23+fi
24+
25+if ! command -v "$BAT" &>/dev/null; then
26+ echo "Could not find the build of bat to benchmark."
27+ case "$BAT" in
28+ "bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
29+ "../../target/debug/debug") echo "Make you sure to 'cargo build' first." ;;
30+ "../../target/debug/release") echo "Make you sure to 'cargo build --release' first." ;;
31+ esac
32+ exit 1
33+fi
34+
1135echo "### Startup time"
1236echo
1337
14−hyperfine --warmup 3 bat
38+hyperfine --warmup 3 "$BAT"
1539
1640echo
1741echo "### Plain text"
1842echo
1943
20−hyperfine --warmup 3 "bat --language txt --paging=never 'test-src/jquery-3.3.1.js'"
44+hyperfine --warmup 3 "$(printf "%q" "$BAT") --language txt --paging=never 'test-src/jquery-3.3.1.js'"
2145
2246echo
2347echo "### Time to syntax-highlight large files"
2448echo
2549
2650for SRC in test-src/*; do
27− hyperfine --warmup 3 "bat --style=full --color=always --paging=never '$SRC'"
51+ hyperfine --warmup 3 "$(printf "%q" "$BAT") --style=full --color=always --paging=never $(printf "%q" "$SRC")"
2852done