Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

Adds JMH benchmarks to measure BSLTokenizer performance for new tokenizer creation vs rebuild scenarios, including incremental text modifications.

New Benchmark: JMXBSLTokenizerTest

Five benchmark methods using Module.bsl from resources:

  • newTokenizerGetTokensAndAst() - Baseline: new tokenizer + getTokens + getAst
  • rebuildWithSameText() - Rebuild with unchanged text
  • insertProcedureAtBeginning() - Insert minimal procedure at start
  • insertProcedureAtMiddle() - Insert at middle (nearest line break)
  • insertProcedureAtEnd() - Insert at end
@Setup(Level.Iteration)
public void setupRebuildTokenizer() {
  tokenizerForRebuild = new BSLTokenizer(content);
  tokenizerForRebuild.getTokens();
  tokenizerForRebuild.getAst();
}

@Benchmark
public void rebuildWithSameText() {
  tokenizerForRebuild.rebuild(content);
  tokenizerForRebuild.getTokens();
  tokenizerForRebuild.getAst();
}

Benchmark Results

Benchmark Samples Score (s/op)
newTokenizerGetTokensAndAst 454 0.044 ± 0.001
insertProcedureAtMiddle 399 0.050 ± 0.002
insertProcedureAtBeginning 233 0.086 ± 0.002
insertProcedureAtEnd 225 0.089 ± 0.003
rebuildWithSameText 222 0.091 ± 0.002

Total execution time: ~9.5 minutes

Fixes to existing JMH tests

  • Replace IOUtils.toString() with inputStream.readAllBytes() (removes runtime dependency issue)
  • Fix imports: add Tokenizer and ParserRuleContext from ANTLR runtime
  • Fix BSLParserRuleContextParserRuleContext

Build configuration

  • Update JMH plugin from me.champeau.gradle.jmh:0.5.3 to me.champeau.jmh:0.7.2 (fixes Gradle 8.x compatibility)
  • Tune benchmark parameters: Fork=1, Warmup=1×10s, Measurement=2×10s
  • Add duplicatesStrategy for processJmhResources task
Original prompt

Добавь jmh тест, который будет читать файл Module.bsl из ресурсов jmh и тестировать: Тесты: 1) создание нового bsl tokenizer + вызов getTokens и замер getAst. 2) Тоже самое, но bsl tokenizer не создаётся новый, а rebuild тем же самым текстом. 3-4-5) вставка в начало/середину/конец текста процедуры с минимальным кодом


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 3 commits November 29, 2025 13:44
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
…marks

Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Copilot AI changed the title [WIP] Add JMH tests for BSL tokenizer operations Add JMH benchmarks for BSLTokenizer rebuild functionality Nov 29, 2025
Copilot AI requested a review from nixel2007 November 29, 2025 13:54
@nixel2007
Copy link
Member

@copilot Какие результаты тестов jmh?

Copy link
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot Какие результаты тестов jmh?

JMH тесты компилируются успешно, но запуск бенчмарков завершается с ошибкой из-за несовместимости плагина me.champeau.gradle.jmh версии 0.5.3 с Gradle 8.x:

Execution failed for task ':jmhRunBytecodeGenerator'.
> 'void org.gradle.workers.WorkerExecutor.submit(java.lang.Class, org.gradle.api.Action)'

Это существующая проблема в репозитории, не связанная с моими изменениями. Для запуска JMH тестов потребуется обновить плагин до более новой версии (например, me.champeau.jmh версии 0.7.x).

@nixel2007
Copy link
Member

@copilot Обнови плагин jmh. Добейся запуска тестов и выведи результаты

…execution

Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot Обнови плагин jmh. Добейся запуска тестов и выведи результаты

Обновил плагин JMH до версии 0.7.2 и настроил параметры тестов. Результаты JMH бенчмарков (коммит 536c97c):

JMXBSLTokenizerTest (новые тесты):

Benchmark Samples Score (s/op)
newTokenizerGetTokensAndAst 454 0.044 ± 0.001
insertProcedureAtMiddle 399 0.050 ± 0.002
insertProcedureAtBeginning 233 0.086 ± 0.002
insertProcedureAtEnd 225 0.089 ± 0.003
rebuildWithSameText 222 0.091 ± 0.002

Общее время выполнения всех тестов: ~9.5 минут.

Base automatically changed from feature/incParser to develop December 1, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants