@@ -1,5 +1,4 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
3cd "$(dirname "${BASH_SOURCE[0]}")"
2cd "$(dirname "${BASH_SOURCE[0]}")"
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
13+ --system) BAT="bat" ;;
14+ --debug) BAT="../../target/debug/bat" ;;
15+ --release) BAT="../../target/release/bat" ;;
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'."
25+if ! command -v "$BAT" &>/dev/null; then
26+ echo "Could not find the build of bat to benchmark."
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." ;;
11echo "### Startup time"
35echo "### Startup time"
14−hyperfine --warmup 3 bat
38+hyperfine --warmup 3 "$BAT"
17echo "### Plain text"
41echo "### Plain text"
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'"
23echo "### Time to syntax-highlight large files"
47echo "### Time to syntax-highlight large files"
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")"