summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/benchmarks/run-benchmarks.sh50
-rw-r--r--tests/benchmarks/startup-time-src/Containerfile3
-rw-r--r--tests/benchmarks/startup-time-src/mystery-file3
3 files changed, 56 insertions, 0 deletions
diff --git a/tests/benchmarks/run-benchmarks.sh b/tests/benchmarks/run-benchmarks.sh
index 0f43bc6b..ea14804c 100755
--- a/tests/benchmarks/run-benchmarks.sh
+++ b/tests/benchmarks/run-benchmarks.sh
@@ -9,6 +9,13 @@ if ! command -v hyperfine > /dev/null 2>&1; then
exit 1
fi
+# Check that jq is installed.
+if ! command -v jq > /dev/null 2>&1; then
+ echo "'jq' does not seem to be installed."
+ echo "You can get it here: https://jqlang.github.io/jq/download/"
+ exit 1
+fi
+
# Check that python3 is installed.
if ! command -v python3 > /dev/null 2>&1; then
echo "'python3' does not seem to be installed."
@@ -117,6 +124,49 @@ hyperfine \
cat "$RESULT_DIR/startup-time-with-syntax-with-dependencies.md" >> "$REPORT"
+heading "Startup time with indeterminant syntax"
+hyperfine \
+ "$(printf "%q" "$BAT") --no-config startup-time-src/mystery-file" \
+ --command-name 'bat … mystery-file' \
+ --warmup "$WARMUP_COUNT" \
+ --runs $(($RUN_COUNT * 100)) \
+ --export-markdown "$RESULT_DIR/startup-time-with-indeterminant-syntax.md" \
+ --export-json "$RESULT_DIR/startup-time-with-indeterminant-syntax.json"
+cat "$RESULT_DIR/startup-time-with-indeterminant-syntax.md" >> "$REPORT"
+
+heading "Startup time with manually set syntax"
+hyperfine \
+ "$(printf "%q" "$BAT") --no-config --language=Dockerfile startup-time-src/mystery-file" \
+ --command-name 'bat … --language=Dockerfile mystery-file' \
+ --warmup "$WARMUP_COUNT" \
+ --runs $(($RUN_COUNT * 100)) \
+ --export-markdown "$RESULT_DIR/startup-time-with-manually-set-syntax.md" \
+ --export-json "$RESULT_DIR/startup-time-with-manually-set-syntax.json"
+cat "$RESULT_DIR/startup-time-with-manually-set-syntax.md" >> "$REPORT"
+
+heading "Startup time with mapped syntax"
+hyperfine \
+ "$(printf "%q" "$BAT") --no-config startup-time-src/Containerfile" \
+ --command-name 'bat … Containerfile' \
+ --warmup "$WARMUP_COUNT" \
+ --runs $(($RUN_COUNT * 100)) \
+ --export-markdown "$RESULT_DIR/startup-time-with-mapped-syntax.md" \
+ --export-json "$RESULT_DIR/startup-time-with-mapped-syntax.json"
+cat "$RESULT_DIR/startup-time-with-mapped-syntax.md" >> "$REPORT"
+
+AVG_TIMES=()
+for KIND in indeterminant manually-set mapped; do
+ JSON_SRC="$RESULT_DIR/startup-time-with-$KIND-syntax.json"
+ AVG=$(jq -r '.results[0].mean' "$JSON_SRC")
+ AVG_TIMES+=("$AVG")
+done
+# indeterminant should be slower, because it necessarily has to evaluate all rules
+# to ensure that nothing matches; manually-set and mapped should both be faster
+# because most or all GlobMatcher builds are skipped
+python3 -c "if ${AVG_TIMES[0]} < ${AVG_TIMES[1]}: print('WARN: indeterminant syntax has faster startup than manually set syntax!')"
+python3 -c "if ${AVG_TIMES[0]} < ${AVG_TIMES[2]}: print('WARN: indeterminant syntax has faster startup than mapped syntax!')"
+
+
heading "Plain-text speed"
hyperfine \
"$(printf "%q" "$BAT") --no-config --language=txt --style=plain highlighting-speed-src/numpy_test_multiarray.py" \
diff --git a/tests/benchmarks/startup-time-src/Containerfile b/tests/benchmarks/startup-time-src/Containerfile
new file mode 100644
index 00000000..a93ce851
--- /dev/null
+++ b/tests/benchmarks/startup-time-src/Containerfile
@@ -0,0 +1,3 @@
+FROM docker.io/alpine:latest
+COPY foo /root/bar
+RUN sleep 60
diff --git a/tests/benchmarks/startup-time-src/mystery-file b/tests/benchmarks/startup-time-src/mystery-file
new file mode 100644
index 00000000..a93ce851
--- /dev/null
+++ b/tests/benchmarks/startup-time-src/mystery-file
@@ -0,0 +1,3 @@
+FROM docker.io/alpine:latest
+COPY foo /root/bar
+RUN sleep 60