Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.benchmark.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Путь к конфигурации EDT (можно заменить на свою)
BENCH_EDT_PATH=src/test/resources/ext/edt/ssl_3_1/configuration

# Путь к конфигурации Designer
BENCH_DESIGNER_PATH=src/test/resources/ext/designer/ssl_3_1/src/cf

# Дополнительные JVM-аргументы для JMH
BENCH_JVM_ARGS=-Xms4g -Xmx8g

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Quote JVM args so the env file can be sourced.

Because benchmark-compare.sh uses source .env.benchmark, Line 8 is parsed by Bash as BENCH_JVM_ARGS=-Xms4g followed by a command named -Xmx8g. This example will fail when copied as-is.

Proposed fix
-BENCH_JVM_ARGS=-Xms4g -Xmx8g
+BENCH_JVM_ARGS="-Xms4g -Xmx8g"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
BENCH_JVM_ARGS=-Xms4g -Xmx8g
BENCH_JVM_ARGS="-Xms4g -Xmx8g"
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 8-8: [ValueWithoutQuotes] This value needs to be surrounded in quotes

(ValueWithoutQuotes)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.env.benchmark.example at line 8, The benchmark env example is missing
quotes around BENCH_JVM_ARGS, so sourcing it will split the JVM flags into a bad
assignment plus a command. Update the BENCH_JVM_ARGS entry in the
.env.benchmark.example template to wrap the full value in quotes so
benchmark-compare.sh can source it safely when copied as-is.

Source: Linters/SAST tools


# Профилировщики JMH (через запятую, без пробелов)
BENCH_PROFILERS=com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Gradle_*.xml
benchmark-results/**

.vscode/
/.env.benchmark
702 changes: 434 additions & 268 deletions benchmark-analyze-results.py

Large diffs are not rendered by default.

126 changes: 99 additions & 27 deletions benchmark-compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

set -e

# Загрузка .env.benchmark если есть
if [ -f ".env.benchmark" ]; then
echo "📄 Загрузка конфигурации из .env.benchmark"
set -a
source .env.benchmark
set +a
fi

# Параметры по умолчанию
QUICK_MODE=false
LABEL_NAME=""
JVM_ARGS="${BENCH_JVM_ARGS:-}"
PROFILERS="${BENCH_PROFILERS:-com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler}"

# Разбор аргументов
POSITIONAL=()
while [[ $# -gt 0 ]]; do
case $1 in
--quick)
QUICK_MODE=true
shift
;;
--label)
LABEL_NAME="$2"
shift 2
;;
--jvm-args)
JVM_ARGS="$2"
shift 2
Comment on lines +27 to +33

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Validate options that require a value.

--label or --jvm-args at the end of the command reads an empty $2 and then shift 2 fails. Add a guard before consuming the value.

Proposed fix
         --label)
+            if [[ $# -lt 2 || "$2" == --* ]]; then
+                echo "❌ --label requires a value"
+                exit 1
+            fi
             LABEL_NAME="$2"
             shift 2
             ;;
         --jvm-args)
+            if [[ $# -lt 2 || "$2" == --* ]]; then
+                echo "❌ --jvm-args requires a value"
+                exit 1
+            fi
             JVM_ARGS="$2"
             shift 2
             ;;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--label)
LABEL_NAME="$2"
shift 2
;;
--jvm-args)
JVM_ARGS="$2"
shift 2
--label)
if [[ $# -lt 2 || "$2" == --* ]]; then
echo "❌ --label requires a value"
exit 1
fi
LABEL_NAME="$2"
shift 2
;;
--jvm-args)
if [[ $# -lt 2 || "$2" == --* ]]; then
echo "❌ --jvm-args requires a value"
exit 1
fi
JVM_ARGS="$2"
shift 2
;;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark-compare.sh` around lines 27 - 33, The option parsing in
benchmark-compare.sh for the --label and --jvm-args cases does not validate that
a following value exists before reading $2 and shifting by 2. Update the
argument-handling logic in the main option switch to guard these branches,
detect missing values for LABEL_NAME and JVM_ARGS, and fail gracefully with a
clear usage/error message instead of attempting to consume an empty argument.

;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done

# Восстанавливаем позиционные аргументы
set -- "${POSITIONAL[@]}"

# Конфигурация для CI
if [ -n "$GITHUB_HEAD_REF" ]; then
# В GitHub Actions
Expand All @@ -13,6 +53,22 @@ else
NEW_BRANCH=${2:-$(git branch --show-current)}
fi

# Режим быстрого замера
if [ "$QUICK_MODE" = true ]; then
JMH_QUICK_ARGS="-f 1 -wi 2 -i 3"
echo "⚡ Быстрый режим: 1 fork, 2 warmup, 3 iterations"
else
JMH_QUICK_ARGS=""
fi

# Имя для маркировки результатов
if [ -n "$LABEL_NAME" ]; then
NEW_VERSION_NAME="$LABEL_NAME"
echo "🏷️ Маркировка результатов: $LABEL_NAME"
else
NEW_VERSION_NAME="new-version"
fi
Comment on lines +64 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Sanitize --label before using it in filenames.

NEW_VERSION_NAME is used to build jar/result/commit paths. Labels with spaces, /, or glob characters break unquoted cat calls and can write outside the results directory.

Proposed fix
 if [ -n "$LABEL_NAME" ]; then
+    if [[ ! "$LABEL_NAME" =~ ^[A-Za-z0-9._-]+$ ]]; then
+        echo "❌ --label may contain only letters, numbers, dot, underscore, and dash"
+        exit 1
+    fi
     NEW_VERSION_NAME="$LABEL_NAME"

Also applies to: 198-202, 458-458

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark-compare.sh` around lines 64 - 70, `LABEL_NAME` is copied directly
into `NEW_VERSION_NAME`, which later feeds jar/result/commit path construction
and can break file handling or escape the results directory. Sanitize and
normalize the value before assigning it in the label-handling block, and make
sure every place that uses `NEW_VERSION_NAME` for path construction or
`cat`-based reads/writes uses the cleaned value consistently. Reference the
`LABEL_NAME`/`NEW_VERSION_NAME` flow in `benchmark-compare.sh` and verify the
downstream path-building logic is safe for spaces, slashes, and glob characters.

Source: Linters/SAST tools


RESULTS_DIR="benchmark-results"
BUILD_DIR="build/libs"

Expand Down Expand Up @@ -85,27 +141,34 @@ build_from_branch() {
exit 1
fi

git checkout "$branch" --quiet
# Из целевой ветки: src/main + билд-система (чтоб зависимости были те)
# Из текущей ветки: src/jmh (чтоб бенч-скрипты были актуальные)
local temp_dir
temp_dir=$(mktemp -d)

echo " Сборка Gradle..."
./gradlew clean jmhJar --quiet
git archive "$branch" build.gradle.kts settings.gradle.kts gradlew gradlew.bat lombok.config gradle.properties gradle/ src/ | tar -x -C "$temp_dir"
cp -r src/jmh "$temp_dir/src/jmh"
Comment on lines +149 to +150

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Replace src/jmh instead of nesting it.

Since the archive includes src/, $temp_dir/src/jmh may already exist. cp -r src/jmh "$temp_dir/src/jmh" then creates $temp_dir/src/jmh/jmh, so the build can still use the branch’s stale benchmark sources.

Proposed fix
     git archive "$branch" build.gradle.kts settings.gradle.kts gradlew gradlew.bat lombok.config gradle.properties gradle/ src/ | tar -x -C "$temp_dir"
-    cp -r src/jmh "$temp_dir/src/jmh"
+    rm -rf "$temp_dir/src/jmh"
+    mkdir -p "$temp_dir/src"
+    cp -r src/jmh "$temp_dir/src/jmh"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
git archive "$branch" build.gradle.kts settings.gradle.kts gradlew gradlew.bat lombok.config gradle.properties gradle/ src/ | tar -x -C "$temp_dir"
cp -r src/jmh "$temp_dir/src/jmh"
git archive "$branch" build.gradle.kts settings.gradle.kts gradlew gradlew.bat lombok.config gradle.properties gradle/ src/ | tar -x -C "$temp_dir"
rm -rf "$temp_dir/src/jmh"
mkdir -p "$temp_dir/src"
cp -r src/jmh "$temp_dir/src/jmh"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark-compare.sh` around lines 149 - 150, The benchmark copy step in
benchmark-compare.sh is nesting the JMH sources instead of replacing them
because git archive already extracts src/ into the temp directory. Update the
copy logic around the git archive and cp flow so src/jmh from the current
checkout replaces the branch’s existing temp_dir/src/jmh contents rather than
creating a nested jmh directory; use the existing benchmark copy section to
remove or overwrite the destination before copying.


git log -1 --oneline > "$RESULTS_DIR/$version_name-commit.txt"
git rev-parse HEAD > "$RESULTS_DIR/$version_name-hash.txt"
echo " Сборка Gradle..."
(cd "$temp_dir" && chmod +x gradlew && ./gradlew clean jmhJar --no-daemon --quiet 2>&1)

sleep 2
git log -1 --oneline "$branch" > "$RESULTS_DIR/$version_name-commit.txt"
git rev-parse "$branch" > "$RESULTS_DIR/$version_name-hash.txt"

local jar_file
jar_file=$(find_benchmark_jar "$BUILD_DIR")
jar_file=$(find_benchmark_jar "$temp_dir/$BUILD_DIR")

if [[ -z "$jar_file" ]]; then
echo " ❌ Не удалось найти JAR файл в $BUILD_DIR"
ls -la "$BUILD_DIR"/*.jar 2>/dev/null || echo " Нет JAR файлов"
echo " ❌ Не удалось найти JAR файл"
ls -la "$temp_dir/$BUILD_DIR"/*.jar 2>/dev/null || echo " Нет JAR файлов"
rm -rf "$temp_dir"
exit 1
fi

echo " ✅ Найден JAR: $(basename "$jar_file")"
cp "$jar_file" "$RESULTS_DIR/$version_name.jar"

rm -rf "$temp_dir"
}

# Основная логика определения способа получения версий
Expand All @@ -132,11 +195,11 @@ fi

# Обрабатываем новую версию
if is_jar_file "$NEW_BRANCH"; then
use_existing_jar "$NEW_BRANCH" "new-version"
use_existing_jar "$NEW_BRANCH" "$NEW_VERSION_NAME"
NEW_SOURCE="JAR файл: $(basename "$NEW_BRANCH")"
elif is_git_branch "$NEW_BRANCH"; then
build_from_branch "$NEW_BRANCH" "new-version"
NEW_SOURCE="Ветка: $NEW_BRANCH ($(cat $RESULTS_DIR/new-version-commit.txt))"
build_from_branch "$NEW_BRANCH" "$NEW_VERSION_NAME"
NEW_SOURCE="Ветка: $NEW_BRANCH ($(cat $RESULTS_DIR/$NEW_VERSION_NAME-commit.txt))"
else
echo "❌ Второй параметр не является ни JAR файлом, ни существующей веткой: $NEW_BRANCH"
exit 1
Expand All @@ -158,25 +221,34 @@ check_jar_exists() {
}

check_jar_exists "$RESULTS_DIR/old-version.jar" "прошлой версии"
check_jar_exists "$RESULTS_DIR/new-version.jar" "новой версии"

# Если использовались ветки, возвращаемся к новой версии для дальнейшей работы
if ! is_jar_file "$NEW_BRANCH" && is_git_branch "$NEW_BRANCH"; then
echo "🔄 Возвращаемся к ветке $NEW_BRANCH..."
git checkout "$NEW_BRANCH" --quiet
fi
check_jar_exists "$RESULTS_DIR/$NEW_VERSION_NAME.jar" "новой версии"

echo ""
echo "🎯 ИСТОЧНИКИ ВЕРСИЙ:"
echo " Прошлая версия: $OLD_SOURCE"
echo " Новая версия: $NEW_SOURCE"
echo ""

# Формируем общие JMH аргументы
JMH_COMMON_ARGS=""
IFS=',' read -ra PROFILER_LIST <<< "$PROFILERS"
for profiler in "${PROFILER_LIST[@]}"; do
JMH_COMMON_ARGS="$JMH_COMMON_ARGS -prof $profiler"
done

JVM_SYS_PROPS=""
if [ -n "$BENCH_EDT_PATH" ]; then
JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.edt.path=$BENCH_EDT_PATH"
fi
if [ -n "$BENCH_DESIGNER_PATH" ]; then
JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.designer.path=$BENCH_DESIGNER_PATH"
fi

echo "📊 Запуск бенчмарков для прошлой версии..."
java -jar "$RESULTS_DIR/old-version.jar" -prof com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler -rf json -rff "$RESULTS_DIR/old-results.json"
java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/old-version.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/old-results.json"

echo "📊 Запуск бенчмарков для новой версии..."
java -jar "$RESULTS_DIR/new-version.jar" -prof com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler -rf json -rff "$RESULTS_DIR/new-results.json"
java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/$NEW_VERSION_NAME.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
Comment on lines +239 to +251

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use arrays for JVM/JMH args that include paths.

BENCH_EDT_PATH and BENCH_DESIGNER_PATH are expanded through string variables, so paths containing spaces are split before java receives the -Dbench.*.path values.

Proposed fix
-JVM_SYS_PROPS=""
+JVM_SYS_PROPS=()
 if [ -n "$BENCH_EDT_PATH" ]; then
-    JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.edt.path=$BENCH_EDT_PATH"
+    JVM_SYS_PROPS+=("-Dbench.edt.path=$BENCH_EDT_PATH")
 fi
 if [ -n "$BENCH_DESIGNER_PATH" ]; then
-    JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.designer.path=$BENCH_DESIGNER_PATH"
+    JVM_SYS_PROPS+=("-Dbench.designer.path=$BENCH_DESIGNER_PATH")
 fi
 
 echo "📊 Запуск бенчмарков для прошлой версии..."
-java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/old-version.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/old-results.json"
+java $JVM_ARGS "${JVM_SYS_PROPS[@]}" -jar "$RESULTS_DIR/old-version.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/old-results.json"
 
 echo "📊 Запуск бенчмарков для новой версии..."
-java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/$NEW_VERSION_NAME.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
+java $JVM_ARGS "${JVM_SYS_PROPS[@]}" -jar "$RESULTS_DIR/$NEW_VERSION_NAME.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
JVM_SYS_PROPS=""
if [ -n "$BENCH_EDT_PATH" ]; then
JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.edt.path=$BENCH_EDT_PATH"
fi
if [ -n "$BENCH_DESIGNER_PATH" ]; then
JVM_SYS_PROPS="$JVM_SYS_PROPS -Dbench.designer.path=$BENCH_DESIGNER_PATH"
fi
echo "📊 Запуск бенчмарков для прошлой версии..."
java -jar "$RESULTS_DIR/old-version.jar" -prof com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler -rf json -rff "$RESULTS_DIR/old-results.json"
java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/old-version.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/old-results.json"
echo "📊 Запуск бенчмарков для новой версии..."
java -jar "$RESULTS_DIR/new-version.jar" -prof com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler -rf json -rff "$RESULTS_DIR/new-results.json"
java $JVM_ARGS $JVM_SYS_PROPS -jar "$RESULTS_DIR/$NEW_VERSION_NAME.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
JVM_SYS_PROPS=()
if [ -n "$BENCH_EDT_PATH" ]; then
JVM_SYS_PROPS+=("-Dbench.edt.path=$BENCH_EDT_PATH")
fi
if [ -n "$BENCH_DESIGNER_PATH" ]; then
JVM_SYS_PROPS+=("-Dbench.designer.path=$BENCH_DESIGNER_PATH")
fi
echo "📊 Запуск бенчмарков для прошлой версии..."
java $JVM_ARGS "${JVM_SYS_PROPS[@]}" -jar "$RESULTS_DIR/old-version.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/old-results.json"
echo "📊 Запуск бенчмарков для новой версии..."
java $JVM_ARGS "${JVM_SYS_PROPS[@]}" -jar "$RESULTS_DIR/$NEW_VERSION_NAME.jar" $JMH_COMMON_ARGS $JMH_QUICK_ARGS -rf json -rff "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 248-248: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 248-248: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 248-248: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 248-248: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 251-251: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 251-251: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 251-251: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 251-251: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark-compare.sh` around lines 239 - 251, The JVM and JMH argument
assembly in benchmark-compare.sh is using plain strings, so BENCH_EDT_PATH and
BENCH_DESIGNER_PATH can be split when they contain spaces. Refactor the argument
handling around JVM_SYS_PROPS, JVM_ARGS, JMH_COMMON_ARGS, and JMH_QUICK_ARGS
into arrays and append each -Dbench.*.path and benchmark flag as отдельные
elements, then invoke java with array expansion so the old-version.jar and
NEW_VERSION_NAME.jar runs preserve path integrity.

Source: Linters/SAST tools


# Обновленная функция анализа для использования правильных источников
analyze_results() {
Expand Down Expand Up @@ -383,15 +455,15 @@ generate_report() {
echo "📈 ПОЛНЫЙ ОТЧЕТ СРАВНЕНИЯ MDClasses" > "$RESULTS_DIR/comparison-report.txt"
echo "===================================" >> "$RESULTS_DIR/comparison-report.txt"
echo "Старая версия: $OLD_BRANCH ($(cat $RESULTS_DIR/old-version-commit.txt))" >> "$RESULTS_DIR/comparison-report.txt"
echo "Новая версия: $NEW_BRANCH ($(cat $RESULTS_DIR/new-version-commit.txt))" >> "$RESULTS_DIR/comparison-report.txt"
echo "Новая версия: $NEW_VERSION_NAME ($(cat $RESULTS_DIR/$NEW_VERSION_NAME-commit.txt))" >> "$RESULTS_DIR/comparison-report.txt"
echo "" >> "$RESULTS_DIR/comparison-report.txt"

# Пробуем детальный анализ
if analyze_results "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/new-results.json" >> "$RESULTS_DIR/comparison-report.txt" 2>/dev/null; then
if analyze_results "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/$NEW_VERSION_NAME-results.json" >> "$RESULTS_DIR/comparison-report.txt" 2>/dev/null; then
echo "✅ Детальный анализ выполнен"
else
echo "⚠️ Детальный анализ не удался, используем простой"
simple_analysis "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/new-results.json" >> "$RESULTS_DIR/comparison-report.txt"
simple_analysis "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/$NEW_VERSION_NAME-results.json" >> "$RESULTS_DIR/comparison-report.txt"
fi
}

Expand All @@ -400,11 +472,11 @@ generate_report
echo ""
echo "✅ Сравнение завершено!"
echo "📄 Отчет: $RESULTS_DIR/comparison-report.txt"
echo "📊 Данные: $RESULTS_DIR/old-results.json и $RESULTS_DIR/new-results.json"
echo "📊 Данные: $RESULTS_DIR/old-results.json и $RESULTS_DIR/$NEW_VERSION_NAME-results.json"
echo "🎯 Сравнение: $OLD_SOURCE → $NEW_SOURCE"

# Показываем краткий анализ в консоли
echo ""
echo "📋 КРАТКИЕ РЕЗУЛЬТАТЫ:"
analyze_results "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/new-results.json" 2>/dev/null || \
simple_analysis "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/new-results.json"
analyze_results "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/$NEW_VERSION_NAME-results.json" 2>/dev/null || \
simple_analysis "$RESULTS_DIR/old-results.json" "$RESULTS_DIR/$NEW_VERSION_NAME-results.json"
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
// прочее
implementation("commons-io:commons-io:2.22.0")

implementation("io.github.1c-syntax:bsl-common-library:0.11.0")
implementation("io.github.1c-syntax:bsl-common-library:0.12.0")
implementation("io.github.1c-syntax:utils:0.7.2")
implementation("io.github.1c-syntax:supportconf:0.16.0")

Expand Down Expand Up @@ -102,6 +102,9 @@ jmh {
fork = 2
resultFormat = "JSON"
resultsFile = file("build/jmh-results.json")
profilers = listOf(
"com.github._1c_syntax.bsl.mdclasses.benchmark.MemoryProfiler"
)
}

tasks.test {
Expand Down
56 changes: 56 additions & 0 deletions docs/en/benchmark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Benchmarks

This project includes JMH benchmarks for measuring performance and memory usage.

## Quick Start

```bash
# Quick single measurement:
./benchmark-compare.sh HEAD HEAD --quick --label my-feature

# Full comparison with develop:
./benchmark-compare.sh develop HEAD
```

## Report Formats

| Format | Purpose | How to Open |
|---|---|---|
| `build/jmh-results.json` | Machine reading, CI | `jq`, python |
| `benchmark-results/comparison-report.txt` | Terminal, commit message | `cat` |
| `benchmark-results/report.html` | Visual review | browser |
| `benchmark-results/comprehensive-analysis-with-values.png` | Quick glance | image viewer |

## Usage

### Branch comparison

```bash
./benchmark-compare.sh <old-branch> <new-branch>
```

### Compare JAR with branch

```bash
./benchmark-compare.sh old-release.jar feature/optimization
```

### Custom fixtures

Copy and edit `.env.benchmark.example` → `.env.benchmark`:

```bash
cp .env.benchmark.example .env.benchmark
# edit EDT/Designer paths
./benchmark-compare.sh develop HEAD
```

### CLI options

| Option | Description |
|---|---|
| `--quick` | Quick mode: 1 fork, 2 warmup, 3 iterations |
| `--label <name>` | Label result files instead of new-version |
| `--jvm-args "<args>"` | JVM arguments for JMH |

For details see the [Russian documentation](../ru/benchmark.md) (in Russian).
Loading
Loading