From 747b15436aca980ea09af88f41e3f14dfb89afba Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 26 Nov 2021 20:58:33 +0100 Subject: [PATCH] run-benchmarks.sh: Add third 'Startup time' variant Using Markdown for a startup test is useful since it has so many dependencies on other syntaxes. So such a test makes sure that lazy-loading of syntaxes work. It is however also useful to measure the startup time of bat when the time to load a syntax is very small, and the measured startup time has mostly non-syntax related causes. Such as: * Parsing arguments * Setting up syntax mapping * Loading themes This commit adds such a test. It uses the CpuInfo syntax which is very small. Only 14 lines, compared to the 1581 lines that Markdown is (not including the size of its included syntaxes). This command can be used to get an approximation of the size of syntaxes, and thus how expensive they are to load: find -name *.sublime-syntax -print0 | xargs --null wc -l | sort -n -r --- tests/benchmarks/run-benchmarks.sh | 14 ++++++++++++-- .../benchmarks/test-src/small-CpuInfo-file.cpuinfo | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/benchmarks/test-src/small-CpuInfo-file.cpuinfo diff --git a/tests/benchmarks/run-benchmarks.sh b/tests/benchmarks/run-benchmarks.sh index f7646b45..d27af3db 100755 --- a/tests/benchmarks/run-benchmarks.sh +++ b/tests/benchmarks/run-benchmarks.sh @@ -95,14 +95,24 @@ cat "$RESULT_DIR/startup-time.md" >> "$REPORT" heading "Startup time with syntax highlighting" hyperfine \ - "$(printf "%q" "$BAT") --no-config --color=always test-src/small-Markdown-file.md" \ - --command-name "bat … small-Markdown-file.md" \ + "$(printf "%q" "$BAT") --no-config --color=always test-src/small-CpuInfo-file.cpuinfo" \ + --command-name "bat … small-CpuInfo-file.cpuinfo" \ --warmup "$WARMUP_COUNT" \ --export-markdown "$RESULT_DIR/startup-time-with-syntax-highlighting.md" \ --export-json "$RESULT_DIR/startup-time-with-syntax-highlighting.json" cat "$RESULT_DIR/startup-time-with-syntax-highlighting.md" >> "$REPORT" +heading "Startup time with syntax with dependencies" +hyperfine \ + "$(printf "%q" "$BAT") --no-config --color=always test-src/small-Markdown-file.md" \ + --command-name "bat … small-Markdown-file.md" \ + --warmup "$WARMUP_COUNT" \ + --export-markdown "$RESULT_DIR/startup-time-with-syntax-with-dependencies.md" \ + --export-json "$RESULT_DIR/startup-time-with-syntax-with-dependencies.json" +cat "$RESULT_DIR/startup-time-with-syntax-with-dependencies.md" >> "$REPORT" + + heading "Plain-text speed" hyperfine \ "$(printf "%q" "$BAT") --no-config --language=txt --style=plain test-src/numpy_test_multiarray.py" \ diff --git a/tests/benchmarks/test-src/small-CpuInfo-file.cpuinfo b/tests/benchmarks/test-src/small-CpuInfo-file.cpuinfo new file mode 100644 index 00000000..bb3b4533 --- /dev/null +++ b/tests/benchmarks/test-src/small-CpuInfo-file.cpuinfo @@ -0,0 +1 @@ +OneColor : AnotherColor