on master help sign in
Add option to specify bat target in run-benchmarks.sh
e3bc41dEthan P
tests/benchmarks/run-benchmarks.sh+28−4
@@ -1,5 +1,4 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2−
3cd "$(dirname "${BASH_SOURCE[0]}")"
2cd "$(dirname "${BASH_SOURCE[0]}")"
4
3
5if ! which hyperfine > /dev/null 2>&1; then
4if ! which hyperfine > /dev/null 2>&1; then
@@ -8,21 +7,46 @@ if ! which hyperfine > /dev/null 2>&1; then
8 exit 1
7 exit 1
9fi
8fi
10
9
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+
11echo "### Startup time"
35echo "### Startup time"
12echo
36echo
13
37
14−hyperfine --warmup 3 bat
38+hyperfine --warmup 3 "$BAT"
15
39
16echo
40echo
17echo "### Plain text"
41echo "### Plain text"
18echo
42echo
19
43
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'"
21
45
22echo
46echo
23echo "### Time to syntax-highlight large files"
47echo "### Time to syntax-highlight large files"
24echo
48echo
25
49
26for SRC in test-src/*; do
50for 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")"
28done
52done