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
1 change: 1 addition & 0 deletions benchmark-compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ BUILD_DIR="build/libs"
echo "🔨 Начало сравнения производительности MDClasses"
echo "================================================"

rm -rf "$RESULTS_DIR"
mkdir -p $RESULTS_DIR

# Функция для проверки является ли параметром JAR файл
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@
*/
package com.github._1c_syntax.bsl.mdclasses.benchmark;

import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings;
import com.github._1c_syntax.bsl.mdclasses.MDClasses;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

Expand All @@ -49,35 +48,42 @@ public class MDClassesBenchmark {

private final Path configPathEDT = Path.of("src/test/resources/ext/edt/ssl_3_1/configuration");
private final Path configPathDesigner = Path.of("src/test/resources/ext/designer/ssl_3_1/src/cf");
private static final MDCReadSettings SKIP_ALL = MDCReadSettings.builder()
.skipSupport(true)
.skipRoleData(true)
.skipFormElementItems(true)
.skipXdtoPackage(true)
.skipDataCompositionSchema(true)
.build();

@Setup
public void setup() {
// Предварительная загрузка для разогрева
MDClasses.createConfiguration(configPathEDT, false);
MDClasses.createConfiguration(configPathDesigner, false);
MDClasses.createConfiguration(configPathEDT);
MDClasses.createConfiguration(configPathDesigner);
}

@Benchmark
public void test_EDT_CreateConfiguration_SkipSupport_False(Blackhole blackhole) {
var model = MDClasses.createConfiguration(configPathEDT, false);
var model = MDClasses.createConfiguration(configPathEDT);
blackhole.consume(model);
}

@Benchmark
public void test_EDT_CreateConfiguration_SkipSupport_True(Blackhole blackhole) {
var model = MDClasses.createConfiguration(configPathEDT, true);
var model = MDClasses.createConfiguration(configPathEDT, SKIP_ALL);
blackhole.consume(model);
}

@Benchmark
public void test_Designer_CreateConfiguration_SkipSupport_False(Blackhole blackhole) {
var model = MDClasses.createConfiguration(configPathDesigner, false);
var model = MDClasses.createConfiguration(configPathDesigner);
blackhole.consume(model);
}

@Benchmark
public void test_Designer_CreateConfiguration_SkipSupport_True(Blackhole blackhole) {
var model = MDClasses.createConfiguration(configPathDesigner, true);
var model = MDClasses.createConfiguration(configPathDesigner, SKIP_ALL);
blackhole.consume(model);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdclasses;

import lombok.Builder;
import lombok.Value;

/**
* Настройки чтения MDC
*/
@Value
@Builder
public class MDCReadSettings {
/**
* Настройки по умолчанию
*/
public static final MDCReadSettings DEFAULT = MDCReadSettings.builder().build();

/**
* Шаблон с отключением только чтения поддержки
*/
public static final MDCReadSettings SKIP_SUPPORT = MDCReadSettings.builder().skipSupport(true).build();

/**
* Пропускать чтение настроек поставки конфигурации
*/
boolean skipSupport;

/**
* Пропускать чтение содержимого ролей
*/
boolean skipRoleData;

/**
* Пропускать чтение содержимого xdto пакетов
*/
boolean skipXdtoPackage;

/**
* Пропускать чтение элементов форм
*/
boolean skipFormElementItems;

/**
* Пропускать чтение элементов макетов системы компоновки
*/
boolean skipDataCompositionSchema;

}
67 changes: 59 additions & 8 deletions src/main/java/com/github/_1c_syntax/bsl/mdclasses/MDClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,30 @@ public ExternalSource createExternalReport() {
* @return Конфигурация или расширение
*/
public MDClass createConfiguration(Path path) {
return createConfiguration(path, false);
return createConfiguration(path, MDCReadSettings.DEFAULT);
}

/**
* Создает конфигурацию или расширение по указанному пути
*
* @param path Путь к корню проекта
* @param readSettings Настройки чтения
* @return Конфигурация или расширение
*/
public MDClass createConfiguration(Path path, MDCReadSettings readSettings) {
return MDOReader.readConfiguration(path, readSettings);
}

/**
* @param path Путь к корню проекта
* @param skipSupport Флаг управления чтением информации о поддержке
* @return Конфигурация или расширение
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
* Создает конфигурацию или расширение по указанному пути
*/
@Deprecated(since = "0.16.0")
public MDClass createConfiguration(Path path, boolean skipSupport) {
return MDOReader.readConfiguration(path, skipSupport);
return createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build());
}

/**
Expand All @@ -103,7 +115,7 @@ public MDClass createExternalSource(Path mdoPath) {
* @return Список прочитанных контейнеров конфигураций и расширений
*/
public List<MDClass> createConfigurations(Path sourcePath) {
return createConfigurations(sourcePath, false);
return createConfigurations(sourcePath, MDCReadSettings.DEFAULT);
}

/**
Expand All @@ -112,10 +124,25 @@ public List<MDClass> createConfigurations(Path sourcePath) {
* @param sourcePath каталог исходных файлов
* @param skipSupport Флаг управления чтением информации о поддержке
* @return Список прочитанных контейнеров конфигураций и расширений
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
*/
@Deprecated(since = "0.16.0")
public List<MDClass> createConfigurations(Path sourcePath, boolean skipSupport) {
return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream()
.map(path -> createConfiguration(path, skipSupport))
.map(path -> createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build()))
.toList();
}

/**
* Возвращает список конфигураций\расширений в указанном каталоге исходных файлов
*
* @param sourcePath каталог исходных файлов
* @param readSettings Настройки чтения
* @return Список прочитанных контейнеров конфигураций и расширений
*/
public List<MDClass> createConfigurations(Path sourcePath, MDCReadSettings readSettings) {
return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream()
.map(path -> createConfiguration(path, readSettings))
.toList();
}

Expand All @@ -126,8 +153,19 @@ public List<MDClass> createConfigurations(Path sourcePath, boolean skipSupport)
* @return Список прочитанных контейнеров внешних отчетов и обработок
*/
public List<MDClass> createExternalSources(Path sourcePath) {
return createExternalSources(sourcePath, MDCReadSettings.DEFAULT);
}

/**
* Возвращает список внешних отчетов и обработок в указанном каталоге исходных файлов
*
* @param sourcePath каталог исходных файлов
* @param readSettings Настройки чтения
* @return Список прочитанных контейнеров внешних отчетов и обработок
*/
public List<MDClass> createExternalSources(Path sourcePath, MDCReadSettings readSettings) {
return findFiles(sourcePath, SEARCH_EX_RES).parallelStream()
.map(MDOReader::readExternalSource)
.map(mdoPath -> MDOReader.readExternalSource(mdoPath, readSettings))
.toList();
}

Expand All @@ -138,7 +176,7 @@ public List<MDClass> createExternalSources(Path sourcePath) {
* @return Список прочитанных контейнеров
*/
public List<MDClass> create(Path sourcePath) {
return create(sourcePath, false);
return create(sourcePath, MDCReadSettings.DEFAULT);
}

/**
Expand All @@ -147,10 +185,23 @@ public List<MDClass> create(Path sourcePath) {
* @param sourcePath каталог исходных файлов
* @param skipSupport Флаг управления чтением информации о поддержке
* @return Список прочитанных контейнеров
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
*/
@Deprecated(since = "0.16.0")
public List<MDClass> create(Path sourcePath, boolean skipSupport) {
var result = new ArrayList<>(createConfigurations(sourcePath, skipSupport));
result.addAll(createExternalSources(sourcePath));
return create(sourcePath, MDCReadSettings.builder().skipSupport(skipSupport).build());
}

/**
* Возвращает список контейнеров метаданных в указанном каталоге исходных файлов
*
* @param sourcePath каталог исходных файлов
* @param readSettings Настройки чтения
* @return Список прочитанных контейнеров
*/
public List<MDClass> create(Path sourcePath, MDCReadSettings readSettings) {
var result = new ArrayList<>(createConfigurations(sourcePath, readSettings));
result.addAll(createExternalSources(sourcePath, readSettings));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage;

import com.github._1c_syntax.bsl.mdo.support.DataSetType;
import com.github._1c_syntax.utils.Lazy;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class DataCompositionSchema implements TemplateData {
/**
* Плоский список наборов данных
*/
List<DataSet> plainDataSets;
Lazy<List<DataSet>> plainDataSets = new Lazy<>(this::computePlainDataSets);

/**
* Путь к файлу с данными макета
Expand All @@ -59,8 +60,6 @@ public class DataCompositionSchema implements TemplateData {

public DataCompositionSchema(@NonNull List<DataSet> dataSetsTree, @NonNull Path path) {
dataSets = dataSetsTree;
plainDataSets = new ArrayList<>();
fillPlaintDataSetByList(dataSetsTree);
dataPath = path;
}

Expand All @@ -69,10 +68,21 @@ public boolean isEmpty() {
return false;
}

private void fillPlaintDataSetByList(List<DataSet> items) {
public List<DataSet> getPlainDataSets() {
return plainDataSets.getOrCompute();
}

private List<DataSet> computePlainDataSets() {
List<DataSet> result = new ArrayList<>();
fillPlainDataSetByList(result, dataSets);

return result;
}

private static void fillPlainDataSetByList(List<DataSet> result, List<DataSet> items) {
items.forEach((DataSet dataSet) -> {
plainDataSets.add(dataSet);
fillPlaintDataSetByList(dataSet.getItems());
result.add(dataSet);
fillPlainDataSetByList(result, dataSet.getItems());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github._1c_syntax.bsl.mdclasses.Configuration;
import com.github._1c_syntax.bsl.mdclasses.ExternalReport;
import com.github._1c_syntax.bsl.mdclasses.ExternalSource;
import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings;
import com.github._1c_syntax.bsl.mdclasses.MDClass;
import com.github._1c_syntax.bsl.mdo.MDObject;
import com.github._1c_syntax.bsl.mdo.storage.EmptyFormData;
Expand Down Expand Up @@ -69,6 +70,12 @@ public Path getRootPath() {
return Path.of("fake-path");
}

@Override
@NonNull
public MDCReadSettings getReadSettings() {
return MDCReadSettings.DEFAULT;
}

@Override
@Nullable
public MDObject read(Path path) {
Expand Down
Loading
Loading