1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 10:52:24 +01:00

Benchmark prototype

This commit is contained in:
cyqsimon
2023-12-11 10:38:59 +08:00
parent d792dc5804
commit f0a6fe216d
6 changed files with 57 additions and 50 deletions

View File

@@ -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" \

View File

@@ -0,0 +1,3 @@
FROM docker.io/alpine:latest
COPY foo /root/bar
RUN sleep 60

View File

@@ -0,0 +1,3 @@
FROM docker.io/alpine:latest
COPY foo /root/bar
RUN sleep 60